Im adding items to TreeView control via ItemsSource property and ItemTemplate property to set the template for TreeViewItem. How can i add an event handler to handle selecti
If you want to capture the SelectedItemChanged event in a TreeView, then you need to set the event handler on the parent node, i.e.,
XAML
Code Behind:
private void OnTreeViewSelectedItemChanged( object sender, RoutedPropertyChangedEventArgs e ) { MyTextBlock.Text = ( (TreeViewItem) ( (TreeView) sender ).SelectedItem ).Header.ToString(); }