【发布时间】:2019-04-27 05:22:43
【问题描述】:
当我双击树项目时,如何禁用树项目折叠/展开?我仍然想通过单击切换按钮来做到这一点,但不是当我双击项目时。
这是我拥有的 XAML:
<TreeView Grid.Column="0" Grid.Row="0" ItemsSource="{Binding Categories}" helpers:TreeViewHelper.SelectedItem="{Binding SelectedCategory, Mode=TwoWay}" >
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type core:Category}" ItemsSource="{Binding SubCategories}">
<Label Content="{Binding Name}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.CreateGroupsFromCategoryCommand , Mode=OneWay}" CommandParameter="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Label>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
我只想在 XAML 中执行此操作。
感谢您的帮助。
【问题讨论】:
标签: wpf xaml mvvm treeview expand