我尝试将复选框的IsEnabled
属性绑定到IsChecked
中另一个复选框的Listview
。有什么问题?
<TreeView ItemsSource="{Binding Rulesets}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Rules}">
<StackPanel Orientation="Horizontal">
<CheckBox Name="rulesetCheckbox" IsChecked="{Binding IsActivated}"></CheckBox>
<TextBlock Text="{Binding Name}" />
</StackPanel>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsEnabled="{Binding ElementName=rulesetCheckbox, Path=IsChecked}" IsChecked="{Binding IsActivated}"></CheckBox>
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
谢谢!