Datagrid Row Wrong Alignement

Asked by At

i am experiencing a strange behaviour using WPF Datagrid. As you can see in the attached pics the sometimes happnes that a row is displayed with a bad "alignement".

Wrong Alignement

Here is the XAML Code of my Datagrid:

<DataGrid Name="DataGridDocs" Margin="10" ItemsSource="{Binding}" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="True" FontSize="15" IsReadOnly="True" HeadersVisibility="Column" AlternatingRowBackground="#FF3CC4A9">
            <DataGrid.ColumnHeaderStyle>
                <Style TargetType="{x:Type DataGridColumnHeader}">
                    <Setter Property="FontWeight" Value="Bold"/>
                </Style>
            </DataGrid.ColumnHeaderStyle>
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem x:Name="menuSelezionaTutti" Header="Seleziona Tutti" Click="menuSelezionaTutti_Click" FontSize="15" />
                    <MenuItem x:Name="menuDeselezionaTutti" Header="Annulla Selezione" Click="menuDeselezionaTutti_Click" FontSize="15" />
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Center">
                                <CheckBox Name="CheckBoxSelected" IsChecked="{Binding Path=SELECTED, Mode=Default, UpdateSourceTrigger=PropertyChanged}" />
                            </ContentControl>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding Path=DOCUMENT_ID}" Header="ID" />
                <DataGridTextColumn Binding="{Binding Path=DESCR}" Header="TIPOLOGIA" />
                <DataGridTextColumn Binding="{Binding Path=COGNOME}" Header="COGNOME" />
                <DataGridTextColumn Binding="{Binding Path=NOME}" Header="NOME" />
                <DataGridTextColumn Binding="{Binding Path=DATA}" Header="DATA" />
                <DataGridTextColumn Binding="{Binding Path=FILENAME}" Header="FILE" />
                <DataGridTextColumn Binding="{Binding Path=COD_PRATICA}" Header="CODICE PRATICA" />
                <DataGridTextColumn Binding="{Binding Path=COD_CARTA}" Header="CODICE CARTA" />
                <DataGridTextColumn Binding="{Binding Path=COD_IVA}" Header="CODICE IVA" />
                <DataGridTextColumn Binding="{Binding Path=COD_CLIENTE}" Header="CODICE CLIENTE" />
                <DataGridTextColumn Binding="{Binding Path=COD_DOCUMENTO}" Header="CODICE DOCUMENTO" />
                <DataGridTextColumn Binding="{Binding Path=DOCUMENT_ID}" Header="DOCUMENT_ID" Visibility="Hidden" />
                <DataGridTextColumn Binding="{Binding Path=FOLDER}" Header="FOLDER" Visibility="Hidden" />
            </DataGrid.Columns>
        </DataGrid>

1 Answers

0
Hussein On

Remove the property HeadersVisibility="Column" and use RowHeaderWidth = 0 instead