Reputation: 341
DataGridColumnHeader.BorderThickness=0 works for me, but not DataGridRow or DataGridCell, any thought?
<DataGrid x:Name="dg">
<DataGrid.Resources>
<Style TargetType="DataGrid">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="0 0 0 1" />
</Style>
</DataGrid.Resources>
</DataGrid>
The result:
Upvotes: 3
Views: 4377
Reputation: 12993
This can be achieved by setting GridLinesVisibility
property to None
.
<DataGrid x:Name="dg" DataGrid.GridLinesVisibility="None">
...
You could play with the following snippet to understand which part of DataGrid
is affected by the BorderThickness
settings- there are 3 border styles, each has a different color.
<DataGrid x:Name="dg" >
<DataGrid.Resources>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Red" />
</Style>
<Style TargetType="DataGrid">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Green" />
</Style>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="0 0 0 1" />
</Style>
</DataGrid.Resources>
</DataGrid>
Upvotes: 5