问题描述
我在行选择模式下使用 DataGrid(即,SelectionUnit="FullRow"
).我只想在用户突出显示一行时删除当前单元格周围的边框,以便进行真正的全行选择(并且没有单元格级别选择).我不介意网格维护当前单元格的概念,我只想删除那个讨厌的当前单元格边框,也许是通过更改当前单元格的样式.最简单的方法是什么?
I am using a DataGrid in row selection mode (i.e., SelectionUnit="FullRow"
). I simply want to remove the border that is being placed around the current cell when the user highlights a row in order to have true full row selection (and no cell level selection). I don't mind the notion of the grid maintaining the current cell, I just want to remove that pesky current cell border, perhaps by changing the style of the current cell. What is the easiest way to do this?
推荐答案
您可以将 DataGridCell
的 BorderThickness
设置为 0
You could set the BorderThickness
for DataGridCell
to 0
<DataGrid ...
SelectionUnit="FullRow">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<!-- Update from comments.
Remove the focus indication for the selected cell -->
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
</Style>
</DataGrid.CellStyle>
<!-- ... -->
</DataGrid>
这篇关于在 FullRow 选择模式下禁用 DataGrid 当前单元格边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!