Manikandan
Manikandan

Reputation: 261

How to set DataGrid DataGridTextColumn Text Trimming?

I'm looking for examples for building a text-trimming for DataGridTextColumn.

In my current DataGridTextColumn, the text is automatically wrapped and the row width grows. I want to add for that text-trimming.

Upvotes: 7

Views: 4329

Answers (1)

Muds
Muds

Reputation: 4116

You can do this:

<DataGridTextColumn>
    <DataGridTextColumn.ElementStyle>
        <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Setter Property="TextTrimming" Value="CharacterEllipsis"/>
        </Style>
    </DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

Upvotes: 19

Related Questions