值转换器和 WPF DataGrid
我在 wpf 中有一个数据网格,我的单元格
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Background" Value="{Binding Value, Converter={StaticResource BinaryGridConverter}, ConverterParameter=1 }"/>
</Style>
</DataGridTextColumn.CellStyle>
一切正常,唯一担心的是转换器不会在选定的单元格上触发。我的问题将更有意义与我的网格的屏幕截图,
当我右键单击任何单元格时,会出现上下文菜单,允许它会将单元格变成绿色,禁止它会将单元格通过转换器变成红色。
我有一个按钮,单击后我需要通过与依赖属性的绑定将网格带回其原始位置。问题是当我更改属性值时,转换器不会为每个单元格触发,它只会为那些未被我修改的单元格触发。
I have a datagrid in wpf, my cell is
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Background" Value="{Binding Value, Converter={StaticResource BinaryGridConverter}, ConverterParameter=1 }"/>
</Style>
</DataGridTextColumn.CellStyle>
Everything works fine, the only concern is the converter does not fire on selected cells. My problem will make more sense with the screenshot of my grid,
when i right click on any cell a context menu appear, on allow it will turn the cell green and on disallow it will turn the cell red through the converter.
i have a button, upon click i need to bring the grid back to its original position, through the binding with the dependencyproperty. The issue is when i change the property value the converter does not fire for every cell, it fires for only those cells that are not modified by me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有足够的代码来准确,但从你的话来看,听起来像是你在代码中的某处手动设置了单元格背景值,这样你就打破了绑定 。
仔细检查是否使用绑定通过依赖属性更改单元格背景,而不是直接更改。
There is not enough code to be exact, but from your words, it sounds like you set the cell background value manually somewhere in your code, and this way you break the binding.
Double check that you change the cell background through the dependency property using the binding, and not directly.