1
votes

Trying to restyle a WPF datagrid. Almost where I need to be, except for one peculiarity: when selecting a row, the contents of all the cells are surrounded by a white border.

enter image description here

I'm at a loss as to how to get rid of this. At the moment, my styling looks like this:

<Style TargetType="{x:Type DataGridRow}">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderBrush" Value="Transparent" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Style.Triggers>
        <Trigger Property="IsSelected" Value="True">
            <Setter Property="Background" Value="#3CACDC" />
            <Setter Property="Foreground" Value="White" />
        </Trigger>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="#90C8E0" />
        </Trigger>
    </Style.Triggers>
</Style>

Plus DataGridCell has an almost identical style set.

It's not clear whether the question How to suppress DataGrid cell selection border? is asking the same question, but the accepted solution of setting FocusVisualStyle to Null doesn't remove the border. It does, however, change the style:

enter image description here

How can I get ride of that border?

1
is there any style except that you posted above? Is it all xaml related to DataGrid? I cannot reproduce a such behavior. Selected row is highlighted by blue color and selected cell has black border.StepUp
Did you ever find a solution for this? I have the same problem. As you mention in your comment, the Accepted Answer doesn't work.waxingsatirical

1 Answers

2
votes

I think you can try styling DataGridCell style

   <DataGrid.CellStyle>
    <Style TargetType="DataGridCell">
        <Setter Property="BorderThickness" Value="0"/>          
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    </Style>
  </DataGrid.CellStyle>