the dotted line you see is the FocusedVisualStyle cell
you need to redefine it to be empty.
2 options (one of them should be correct, but since I did not have time to try, I do not know which one)
- VisualStyle is installed directly in the cell
this means that you must set it through the CellStyle property:
<DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="FocusVisualStyle" Value="{x:Null}"/> </Style> </DataGrid.CellStyle>
or if you want to follow the recommendations on MS templates:
<DataGrid.Resources> <Style x:Key="CellFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Border> <Rectangle StrokeThickness="0" Stroke="#00000000" StrokeDashArray="1 2"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </DataGrid.Resources> <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="FocusVisualStyle" Value="{StaticResource CellFocusVisual}"/> </Style> </DataGrid.CellStyle>
(so you can see how this is done)
- another option: this is done using
ElementStyle or EditingElementStyle
it has more hasle there because ElementStyle and EditingElementStyle defined in a column, which means you need to edit each column of ElementStyle and EditingElementStyle .
but basically itβs the same thing: you set FocusVisualStyle to null or the style defined above through ElementStyle and / or EditingElementStyle in each column
source share