I saw another answer that was close, but he did not get rid of the Focus rectangle. Here's how to destroy all boundaries.
<DataGrid.Resources> <Style TargetType="{x:Type DataGridCell}"> <Setter Property="BorderThickness" Value="0" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> </Style> </DataGrid.Resources>
Also, since technically these cells still get focus (you just don't see it) to make a tab to the next row instead of the next cell, I define the cell style based on the above, but also adds the following ...
<DataGrid.Resources> <Style x:Key="NoFocusDataGridCell" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource {x:Type DataGridCell}}"> <Setter Property="Focusable" Value="False" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="IsHitTestVisible" Value="False" /> </Style> </DataGrid.Resources>
... then I apply this to all but the definition of the first column. Thus, the tab key moves to the next line, and not to the next cell.
Back to the borders. If you want to hide them, but still want them to be part of the layout for layout, change the above to this ...
<DataGrid.Resources> <Style TargetType="{x:Type DataGridCell}"> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> </Style> </DataGrid.Resources>
Enjoy! :)
MarqueIV Jun 04 '15 at 10:34 2015-06-04 10:34
source share