Skip to content

Vertical Centering of DataGrid Cells #3999

@OMGCHEN

Description

@OMGCHEN

Bug explanation

When I set the RowHeight and configured VerticalAlignment for the cell style, why do extra border lines appear?

        <DataGrid Grid.Row="3" Grid.Column="1" Background="Transparent" 
                  ItemsSource="{Binding Group.AtQCList}"
                  Style="{StaticResource MaterialDesignDataGrid}"
                  AutoGenerateColumns="False"
                  IsReadOnly="True"
                  RowHeight="50"
                  md:DataGridAssist.SelectedCellBorderBrush="Transparent">
            <DataGrid.CellStyle>
                <Style TargetType="DataGridCell" BasedOn="{StaticResource MaterialDesignDataGridCell}">
                    <Setter Property="VerticalAlignment" Value="Center" />
                </Style>
            </DataGrid.CellStyle>
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}">
                </DataGridTextColumn>
                <DataGridTextColumn Header="Mobile" Binding="{Binding Mobile}" />
            </DataGrid.Columns>
        </DataGrid>
Image

If I leave VerticalAlignment as its default value Stretch, the display works fine, but the cell content cannot be vertically centered.

Image

Version

5.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugevaluation requiredItems is pending review or evaluation by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions