我有
XAML:
<StackPanel >
<TextBlock Text="Simple TreeView with 3 level hierarchy" />
<TreeView >
<TreeViewItem Header='Heading 1'>
<TreeViewItem Header='SubHeading 1.1'>
<TreeViewItem Header="Leaf 1.1.1"/>
<TreeViewItem Header="Leaf 1.1.2"/>
</TreeViewItem>
<TreeViewItem Header='SubHeading 1.2'>
<TreeViewItem Header="Leaf 1.2.1"/>
<TreeViewItem Header="Leaf 1.2.2"/>
</TreeViewItem>
<TreeViewItem Header='SubHeading 1.3'/>
<TreeViewItem Header='SubHeading 1.4'/>
</TreeViewItem>
<TreeViewItem Header='Heading 2'>
<TreeViewItem Header='SubHeading 2.1'/>
<TreeViewItem Header='SubHeading 2.2'/>
<TreeViewItem Header='SubHeading 2.3'/>
<TreeViewItem Header='SubHeading 2.4'/>
</TreeViewItem>
</TreeView>
</StackPanel>
当前行为
预期行为
即。在父节点的这种折叠上,它触发SelectedItemChanged事件,将当前SelectedItem更新为父节点。如何使Selected节点与子节点保持完整并且不更新它?