Listview Checkbox.IsEnabled绑定到父Checkbox.IsChecked

时间:2016-06-22 11:16:11

标签: c# wpf xaml listview checkbox

我尝试将复选框的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>

谢谢!

0 个答案:

没有答案