我试图通过 IValueConverter 使隐式生成的 TreeViewItems 折叠。我的代码删除了网格,但网格位于 TreeViewItem 中。如何使用 IValueConverter 使 TreeViewItem 折叠?
<TreeView Name="TreeViewNew"
Background="Transparent"
HorizontalContentAlignment="Stretch"
VirtualizingStackPanel.IsVirtualizing="True"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=MapLayers}">
<Grid>
<TextBlock
Focusable="False"
Width="150"
Text="{Binding Path=Name}"
FontSize="10"
TextWrapping="Wrap"
Background="Transparent"
HorizontalAlignment="Center"
/>
</Grid>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate >
<Grid Visibility="{Binding Path=Layer, Converter={StaticResource cIsDrawingLayer}}">