Get parent TreeViewItem of a selected node in WPF
问题 I want the parent of a node that is selected as TreeViewItem I have a Person class with 2 fields. Name(String) and Children(List of string) This is my xaml code <Grid x:Name="gridView" Margin="10"> <TreeView Name="treeView1" TreeViewItem.Selected="TreeViewItem_OnItemSelected" ItemsSource="{Binding}"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Source=Check, Mode=TwoWay}" /> </Style> </TreeView