如何抑制DataGrid单元格选择边框?
我已尝试按照此处的建议设置边框样式 禁用 DataGrid 当前单元格FullRow 选择模式中的边框,但它并没有完全完成该操作。当您使用鼠标进行选择时,会禁用单元格边框选择,但在使用键盘进行选择时,仍然会出现虚线单元格边框。有什么建议吗?
I've tried setting border style as suggested here Disable DataGrid current cell border in FullRow selection mode, but it doesn't do the thing fully. Is disables cell border selection when you select using a mouse, but there is still a dashed cell border when making selection using keyboard. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您看到的虚线框是单元格的
FocusedVisualStyle
您需要覆盖它,使其为空白。
这里有 2 个选项(其中一个必须是正确的,但因为我没有时间尝试,我不知道哪个)
,这意味着你必须通过
CellStyle
属性:或者如果您想遵守 MS 的模板指南:(
这样,您可以看到它是如何完成的)
ElementStyle
或 < code>EditingElementStyle那里比较麻烦,因为
ElementStyle
和EditingElementStyle
是在列上定义的,这意味着您必须编辑每个列的ElementStyle
和EditingElementStyle
。但基本上,这是同一件事:您将 FocusVisualStyle 设置为 null 或通过每列上的
ElementStyle
和/或EditingElementStyle
上面定义的样式the dashed box you see is the cell's
FocusedVisualStyle
you need to override it so that it is blank.
2 options here (one of them has to be the right one but as I didn't have time to try, I don't know which)
this means you have to set it through the
CellStyle
property:or if you want to comply with MS's templating guidelines:
(this way, you can see how it is done)
ElementStyle
or theEditingElementStyle
this is more of a hasle there, because the
ElementStyle
andEditingElementStyle
are defined on the Column, wich means you have to edit each column'sElementStyle
andEditingElementStyle
.but basically, this is the same thing: you set up the FocusVisualStyle to null or the style defined above through the
ElementStyle
and/orEditingElementStyle
on each Column您可以将 Focusable 设置为 False。
请注意,如果将 DataGridCell.Focusable 设置为 false,则使用向上/向下箭头键在数据网格中导航将不起作用。
You can set Focusable to False.
Note that if you make DataGridCell.Focusable false then navigation in the datagrid with up/down arrow keys won't work.