C# 可观察集合c中的WPF未响应复选框
我有这个代码,其中我有一个带有复选框的可观察集合类型Herarhy模型的代码。 在某些事件中,我将复选框设置为禁用 问题是: -当我使用debbuger运行代码时,我看到它确实更改为禁用,但在接口上没有看到更改C# 可观察集合c中的WPF未响应复选框,c#,wpf,checkboxlist,C#,Wpf,Checkboxlist,我有这个代码,其中我有一个带有复选框的可观察集合类型Herarhy模型的代码。 在某些事件中,我将复选框设置为禁用 问题是: -当我使用debbuger运行代码时,我看到它确实更改为禁用,但在接口上没有看到更改 我认为这是一些可以观察到的东西。 此外,当我从可观察集合中移除该项并再次将其放回时,它会进行更新 <ListView.View> <GridView AllowsColumnReorder="False"> <GridViewColum
我认为这是一些可以观察到的东西。 此外,当我从可观察集合中移除该项并再次将其放回时,它会进行更新
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Width="50" Header=" ">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsBulkUpdatedChecked}" IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsBulkUpdatedEnabled}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="175" Header="Project Name" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Width="120" Header="Code" DisplayMemberBinding="{Binding Code}"/>
<GridViewColumn Width="120" Header="Step" DisplayMemberBinding="{Binding SelectedStep}"/>
<GridViewColumn Width="150" Header="Version Name" DisplayMemberBinding="{Binding ActiveVersion}"/>
</GridView>
Visual Studio中的“输出”窗口中应该有一个错误,它会告诉您以下信息: System.Windows.Data错误:40:BindingExpression路径错误:在“object”ListViewItem“Name=”上找不到“IsBulkUpdatedChecked”属性。BindingExpression:Path=IsBulkUpdatedChecked;DataItem='ListViewItem'名称='This';目标元素为“CheckBox”Name=;目标属性是“IsChecked”类型“Object” 这是因为ListViewItem类没有IsBulkUpdatedChecked属性。您不应该使用该绑定路径,而应该使用指向您实际定义该属性的位置的路径。我不能告诉你那在哪里,因为你懒得带我们去。我只能猜测它在对象集中设置为Window.DataContext属性值。。。在这种情况下,请尝试以下方法:
<CheckBox IsChecked="{Binding DataContext.IsBulkUpdatedChecked,
RelativeSource={RelativeSource AncestorType={x:Type Window}}}" IsEnabled="{Binding
DataContext.IsBulkUpdatedChecked, RelativeSource={RelativeSource
AncestorType={x:Type Window}}}"/>
什么是等级制度?您正在属性的getter/setter中使用它。另外,尝试将BindingMode设置为CheckBoxe的IsChecked为twoway,我认为这是observable集合中的一些东西。此外,当我从可观察集合中移除该项并再次将其放回时,它会进行更新。
<CheckBox IsChecked="{Binding DataContext.IsBulkUpdatedChecked,
RelativeSource={RelativeSource AncestorType={x:Type Window}}}" IsEnabled="{Binding
DataContext.IsBulkUpdatedChecked, RelativeSource={RelativeSource
AncestorType={x:Type Window}}}"/>