wpfwpfdatagridwpf-4.0

Disable DataGrid current cell border in FullRow selection mode


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?


Solution

  • 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>