Skip to content

set TextBlock.TextAlignment to Right in DataGridTextColumn.ElementStyle will cause text overflow to right edge #11394

@ahdung

Description

@ahdung

Description

set TextBlock.TextAlignment to Right in DataGridTextColumn.ElementStyle will cause text overflow to right edge.

Image

two thing can eliminate this:

  1. drag move to change column width
    Image

  2. when content longer than header
    Image

Reproduction Steps

Create a .net9.0-windows wpf project, and make a DataGrid like this:

<DataGrid>
  <DataGrid.Columns>
    <DataGridTextColumn Header="sss" Binding="{Binding}">
      <DataGridTextColumn.ElementStyle>
        <Style TargetType="TextBlock">
          <Setter Property="Background" Value="CornflowerBlue"></Setter><!--for check-->
          <Setter Property="TextAlignment" Value="Right"></Setter>
        </Style>
      </DataGridTextColumn.ElementStyle>
    </DataGridTextColumn>
  </DataGrid.Columns>
  <DataGrid.Items>
    <system:String>0</system:String>
  </DataGrid.Items>
</DataGrid>

Expected behavior

Image

Actual behavior

see description.

Regression?

I don't know

Known Workarounds

No response

Impact

No response

Configuration

.net9.0-windows wpf project
windows 10 22H2 x64 chinese lang

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions