private void TreeViewItem_OnItemSelected(object sender, RoutedEventArgs e) { nameTxt.Text = e.Source.ToString(); }
using System.Windows; using System.Windows.Controls; namespace SampleApplication.Ui { public partial class MainWindow : Window { public MainWindow() { // InitializeComponent(); // not really needed, // because this sample is fully programmatical; // you don't even need XAML if you properly write // your entry-point method (Main) TreeView treeView = new TreeView(); TreeViewItem top = new TreeViewItem(); top.Header = "sample header"; TreeViewItem child = new TreeViewItem(); child.Header = "sample child"; TreeViewItem grandchild = new TreeViewItem(); grandchild.Header = "sample grandchild"; treeView.Items.Add(top); top.Items.Add(child); child.Items.Add(grandchild); this.AddChild(treeView); } //MainWindow } //class MainWindow } //namespace SampleApplication.Ui
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)