I would like to customize the style of the user cell so that it does not have borders on all the states: selected / not selected. I wrote the following style:

<DataGrid.Resources> <Style TargetType="DataGridCell" x:Key="borderNone"> <Setter Property="BorderThickness" Value="0" /> </Style> </DataGrid.Resources> 

It works almost as it should. Namely, removes the boundary of the selection cell. But, the following problem remains:

enter image description here

This is the black border on the right and bottom of the cell. Visible in all states. How to remove it? Thank. Just in case, the complete table code (this cell is own, customized):

 <DataGrid Name="thread1" AutoGenerateColumns="False" CanUserAddRows="False" Background="White" IsReadOnly="true" Width="300" Height="443" VerticalAlignment="Top" HorizontalAlignment="Left" HeadersVisibility="Column"> <DataGrid.Resources> <Style TargetType="DataGridCell" x:Key="borderNone"> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Padding" Value="0" /> <Setter Property="Margin" Value="0" /> <Setter Property="Background" Value="Transparent"/> </Style> </DataGrid.Resources> <DataGrid.Columns> <DataGridTemplateColumn Header="Поток №1" Width="*" CellStyle="{StaticResource borderNone}"> <DataGridTemplateColumn.HeaderStyle> <Style TargetType="DataGridColumnHeader"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </DataGridTemplateColumn.HeaderStyle> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <DataGrid ItemsSource="{Binding DataThreadsAll}" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="true" HeadersVisibility="Column" BorderThickness="0"> <DataGrid.Columns> <DataGridTextColumn Width="*" Header="Ri" Binding="{Binding Ri}" /> <DataGridTextColumn Width="*" Header="Zi" Binding="{Binding Zi}" /> <DataGridTextColumn Width="*" Header="Tk" Binding="{Binding Tk}" /> </DataGrid.Columns> </DataGrid> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid> 
  • one
    HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" , well, or GridLinesVisibility="None" at the first grid - EvgeniyZ
  • @EvgeniyZ came, thank you very much. - Range

1 answer 1

The DataGrid has the so-called "grid lines" (those that separate each cell vertically and horizontally). So, as you have a nested DataGrid (without padding or anything else), their lines merge into one solid.

The solution here is trivially simple, set these lines to color (transparent for example) using HorizontalGridLinesBrush / VerticalGridLinesBrush , or remove them altogether using GridLinesVisibility .