WPF DataGridTemplateColumn IsSelected ForgroundColor 未按预期工作
我有一个 DataGrid
,其中包含多个 DataGridTemplateColumns
。 我的问题是当前选定的行会将某些单元格前景变为白色,即使文本变为白色。 包含 TextBlock 的 DataGridTemplateColumns
行为正常并变为白色,而包含 TextBox 的 DataGridTemplateColumns
在选择行时不会更改。
有谁知道为什么或如何解决这个问题?
我已经尝试过这个 解决方案: 但它只能使 TextBlocks 受到影响,有人知道可能出了什么问题吗?
I have a DataGrid
that contains several DataGridTemplateColumns
.
My problem is that the currently selected row will turn some of the cells foregrounds to white, i.e. make the text white.DataGridTemplateColumns
that contain TextBlocks behave correctly and turn white while DataGridTemplateColumns
that contain TextBoxs do not change when the row is selected.
Does anybody know why or how to fix this problem?
I have tried this solution: but it can only get TextBlocks to be affected, does anybody know what might be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太确定为什么触发器也不会影响 TextBox ForeGround,但通常当单元格处于编辑模式时,选择颜色不应该处于活动状态,因此这可能是 TextBox 拒绝该值的原因,但我没有把握。如果您使用 DataGridTextColumn 并进入编辑模式,您将看到相同的效果,TextBox 将不会具有触发器的前景,但 TextBlock 会有。要将白色前景应用到 DataGrid 中所有选定的文本框,您可以执行此操作(请注意,这也会影响处于编辑模式的文本框)
I'm not really sure why the Trigger won't effect a TextBox ForeGround as well but normally the selection color shouldn't be active when the cell is in edit mode so that might be the reason the TextBox rejects the value but I'm not sure. You'll see the same effect if you use a DataGridTextColumn and enter edit mode, the TextBox won't have the foreground from the Trigger but the TextBlock will. To apply a White ForeGround to all selected TextBoxes in the DataGrid you can do this (note that this will also effect a TextBox that's in edit mode)