I use XamDataGrid to show table with really long header names. Most important part of the header name is it's suffix.
Is there any way that I can configure column headers the way that when the column width is shorter than text size i will see the suffix as header?
Example:
Required outcome:
[...SUFFIX1][...SUFFIX2]
Instead of default behaviour I have:
[Prefix....][Prefix....]
A way is to create ContentTemplate for LabelPresenter :
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FlowDirection="RightToLeft" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"
TextTrimming="CharacterEllipsis">
</TextBlock>
</DataTemplate>
</Setter.Value>
the result looks like :

for showing the suffix part you can use textwrapping and increasing the height of the LabelPresenters to wrap text. It's a better way to show whole column name and it looks good also.(obviously if this servers your purpose)
<Setter Property="Height" Value="50"/>
set labelPresenter height in style & result looks like :

But if you want strictly as you mentioned then use a control as in below link and then use that control in content template of label presenter.
Textbox with ellipsis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With