0
votes

Hope someone can help with this. I've got a WPF datagrid (see code below). As you can see, I've set the GridLinesVisibility to Vertical and yet, Horizontal grid lines can be seen (please see image below; I need to get rid of the thin horizontal yellow lines). I created a simple WPF datagrid and then set the GridLinesVisibility to Vertical and it didn't display the horizontalgridlines. So I'm not sure what is causing the HorizontalGridLines to be displayed. Any ideas how I can get rid of them? Unfortunately I need to have the RowBackground colour set for the entire Grid and then set the row background for a column depending on the data being displayed.

Screenshot of my Grid. I need to get rid of the thin horizontal yellow lines

<DataGrid TabIndex="8" x:Name="fg" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="4" Margin="5" RowHeaderWidth="0"  ContextMenu="{StaticResource menuContext}"
              ItemsSource="{Binding AssetPPM2GridEntityCollection}" ColumnHeaderStyle="{StaticResource ColumnContextMenus}" HeadersVisibility="{Binding HeaderVisibility}"
              SelectedIndex="{Binding GrdFgSelectedIndex}" AutoGenerateColumns="False" SelectionUnit="FullRow"  SelectionMode="Extended"
              EnableRowVirtualization="True" EnableColumnVirtualization="False" RowBackground="PapayaWhip"
              VirtualizingPanel.VirtualizationMode="Standard" CanUserReorderColumns="False" 
              CanUserAddRows="False" GridLinesVisibility="Vertical" CanUserSortColumns="True" CanUserResizeColumns="False"                 
              dp:DataGridMergeCellBehavior.IsMerged="{Binding Source={StaticResource assetPPM2ViewModel}, Path=IsMergeCellsChecked}"
              PreviewMouseWheel="fg_PreviewMouseWheel">
1
This does not look like grid line. Since this is the same colour as your background on other cells my bet would be on some padding/margin on the grid cell contentdkozl
Setting GridLinesVisibility="Vertical" should do the trick. Check if you are styling the cell to have borders.Anand Murali
Thanks Anand, your suggestion to check styling around borders helped me to arrive at the solution.Andrew N

1 Answers

0
votes

The lines were caused by borders being added to the cells. The borders caused a shift which made the background colour of the row visible. The fix was to move the margin back a couple of pixels.