Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
XamGrid - How to wrap text in header cells
posted

Hello,

we want to set an initial column width and therefore need to activate text wrapping in column headers. I found some messages about this problem in the forum but no solution how to realize that.

Up to now I tried the following:

1. I create a TextColumn in code behind:

TextColumn col = new TextColumn();
col.Key = "[rg" + iRG.ToString() + "fct" + iF.ToString() + "]";
col.HeaderText = _selFacts[iF - 1].Name;
col.Width = new ColumnWidth(100, false);
col.HeaderTemplate = (DataTemplate)FindResource("HeaderCellTemplateForTextWrapping");

The Key is created dynamically and the HeaderText is the name of a Fact (e.g. "Turnover [abs.]"). I set the HeaderTemplate.

2. I define the DataTemplate in XAML:

<DataTemplate x:Key="HeaderCellTemplateForTextWrapping" DataType="{x:Type igPrim:HeaderCellControl}">
    <TextBlock Text="{Binding HeaderTextProperty}" TextWrapping="WrapWithOverflow" />
</DataTemplate>

I alsol tried setting the Datatype to "ig:TextColumn" and tried different Bindings like:

        Text="{Binding Path=TextColumn.HeaderText}"
        Text="{Binding Path=HeaderText}"
        Text="{Binding Path=HeaderTextProperty}"
        Text="{Binding Path=TextColumn.HeaderTextProperty}

Up to now nothing worked. I only get empty header cells. Could you please tell me what I must do to get text wrapping?

Regards