Ranganath L

Ranganath L

  • NA
  • 112
  • 2.6k

Rename the child nodes

Sep 12 2018 2:06 AM
Hi,
 
How to Rename the child nodes of a dynamically loaded tree in WPF.
I am creating My Tree View Programatically in C#.
I want to Edit the Child nodes of the tree on double click. How can i achieve this.
 
This is .CS File
 
private void LoadTree1()
{
TreeViewItem treeItem = null;
treeItem = new TreeViewItem();
treeItem.Header = "North America";
treeItem.IsExpanded = true;
treeItem.Items.Add(new TreeViewItem() { Header = "USA" });
treeItem.Items.Add(new TreeViewItem() { Header = "Canada" });
treeItem.Items.Add(new TreeViewItem() { Header = "Mexico" });
tvMain.Items.Add(treeItem);
}
 
This is my XAML file
 
<TreeView Grid.Row="0" x:Name="tvMain">
</TreeView>
 
 
 
I should be able to edit USA,Mexico or Canada on double click on them.Pls help me out to achieve this
 
Thanks in Advance

Answers (1)