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?
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
You could set the
BorderThickness
forDataGridCell
to 0If you're using the
xceed
DataGridControl
then set theNavigationBehavior
toRowOnly
Saw another answer here that was close, but it didn't get rid of the Focus rectangle. Here's how to obliterate all of the borders.
Also, since technically those cells still do get focus (you just don't see it), to make the tab key advance to the next row instead of the next cell, I define a cell style based on the above but which also adds the following...
...then I apply that to all but the first column definition. That way the tab key advances to the next row, not the next cell.
Back to the borders however. If you want to hide them but still want them to be part of the layout for spacing-reasons, change the above to this...
Enjoy! :)
If you want to show a border only when the cell is editable and selected you can override the DataGridCell template and add a multitrigger for when the cell IsSelected and not IsReadOnly. Then no border will be shown for cells if you set IsReadOnly = true for the column or DataGrid
Use the template in a style
And use the style