kostey2204 kostey2204 - 11 days ago 7
C# Question

How to set grid lines in a one pixel width (WPF DataGrid)?

I am using the WPF datagrid to display some data and I want to grid lines thickness was equal to one pixel, but each cell displays unwanted border. How to get rid of it and set thickness of all lines to one pixel (like in DataGridView in WinForms)?

XAML:
<DataGrid HeadersVisibility="Column" SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding ID}"/>
<DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
</DataGrid.Columns>
</DataGrid>


Result:
unwanted borders

Answer

This is the solution! Settig parameter RenderOptions.EdgeMode="Aliased" Many thanks to David Kossoglyad for this solution.

<DataGrid RenderOptions.EdgeMode="Aliased" UseLayoutRounding="True" ....>