【发布时间】:2011-02-24 23:22:06
【问题描述】:
我有以下(简化的)风格:
<Style x:Key="MyStyle" TargetType="{x:Type CheckBox}">
<Setter Property="Background" Value="Blue" />
</Style>
如果我将它用作 DataGridCheckBoxColumn 中的 ElementStyle 和 EditingElementStyle:
<DataGridCheckBoxColumn Binding="{Binding IsEnabled}"
ElementStyle="{StaticResource MyStyle}"
EditingElementStyle="{StaticResource MyStyle}" />
然后,当我选中/取消选中一行的复选框时,我的绑定 IsEnabled 不会切换。如果我删除 ElementStyle、EditingElementStyle 或两者中的任何一个,则绑定更新没有问题。这是为什么?!
另外,我尝试使用以下代码解决此问题:
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsEnabled}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
但是,问题仍然存在。
【问题讨论】: