3

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....]
Sean Beanland
  • 1,098
  • 1
  • 10
  • 25
Sergey Kucher
  • 4,140
  • 5
  • 29
  • 47

1 Answers1

3

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 :

enter image description here

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 :

enter image description here

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

Kylo Ren
  • 8,551
  • 6
  • 41
  • 66