Removing all borders on wpf datagrid

Viewed 4370

I am a bit new to WPF and I can't find a way to get totally rid of all borders, padding and margin in the cells. What I would like is to have no white at all in the table and only a simple horizontal line between the roes.

Here is a screenshot of what I get:

enter image description here

Here is a screenshot of what I would like to get:

enter image description here

So far I have this simplified code:

<DataGrid IsReadOnly="True" AllowDrop="True" ItemsSource="{Binding Mode=OneWay, Source={StaticResource imageInfoListView}}" 
              AutoGenerateColumns="False" HorizontalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ColumnWidth="*" 
              FontSize="10" GridLinesVisibility="Horizontal" CanUserResizeColumns="False" 
              CanUserResizeRows="False" BorderThickness="0">            
        <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
                <Setter Property="Margin" Value="0"/>
                <Setter Property="Padding" Value="0"/>
            </Style>
        </DataGrid.CellStyle>
        <DataGrid.ColumnHeaderStyle>
            <Style TargetType="{x:Type DataGridColumnHeader}">
                <Setter Property="ContentTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock TextWrapping="WrapWithOverflow" Text="{Binding}" TextAlignment="Center" FontSize="9"/>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </DataGrid.ColumnHeaderStyle>            
            <DataGridCheckBoxColumn Header="Guides" Binding="{Binding Guides}">
                <DataGridCheckBoxColumn.CellStyle>
                    <Style TargetType="{x:Type DataGridCell}">
                        <Setter Property="Background" Value="{Binding GuidesBrush}"/>
                    </Style>
                </DataGridCheckBoxColumn.CellStyle>
            </DataGridCheckBoxColumn>
            <DataGridTextColumn Header="Width" Binding="{Binding Width}">
                <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="Background" Value="{Binding WidthBrush}"/>
                    </Style>
                </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>
            <DataGridTextColumn Header="Height" Binding="{Binding Height}">
                <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="Background" Value="{Binding HeightBrush}"/>
                    </Style>
                </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>
            <DataGridTextColumn Header="Resolution" Binding="{Binding Resolution}">
                <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="Background" Value="{Binding ResolutionBrush}"/>
                    </Style>
                </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>
            <DataGridTextColumn Header="Icc Model" Binding="{Binding IccModel}">
                <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="Background" Value="{Binding IccModelBrush}"/>
                    </Style>
                </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>
            <DataGridTextColumn Header="Compression" Binding="{Binding Compression}">
                <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="Background" Value="{Binding CompressionBrush}"/>
                    </Style>
                </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>
            <DataGridTextColumn Header="Errors" Binding="{Binding Errors}" Visibility="Hidden" />
        </DataGrid>

But I find no way to completely remove everything I don't want. Any clue?

1 Answers
Related