e.Column.HeaderText = $"NormalHeadline\r\nShortHeadline\r\nLongLongLongHeadline";
<syncfusion:GridTextColumn
MappingName="Number" >
<syncfusion:GridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="NormalHeadline ShortHeadline LongLongLongHeadline"
TextAlignment="Center" TextWrapping="Wrap"/>
</DataTemplate>
</syncfusion:GridTextColumn.HeaderTemplate>
</syncfusion:GridTextColumn> |
<Application.Resources> <local:ViewModel x:Key="viewmodel"/> <DataTemplate x:Key="datatemplate"> <TextBlock Text="{Binding TextValue}" DataContext="{StaticResource viewmodel}" TextAlignment="Center" TextWrapping="Wrap"/> </DataTemplate> </Application.Resources> |
private void grid_AutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e) { if(e.Column.MappingName == "Number") { e.Column.HeaderTemplate = Application.Current.Resources["datatemplate"] as DataTemplate; } } |
<DataTemplate x:Key="CenteredColumnHeaderTemplate"><TextBlock TextAlignment="Center" TextWrapping="Wrap"/></DataTemplate>
e.Column.HeaderText = "...";
FrameworkElementFactory textBlock = new FrameworkElementFactory(typeof(TextBlock)); textBlock.SetValue(TextBlock.TextProperty, headerText); textBlock.SetValue(StyleProperty, FindResource("GridColumnHeaderTextBlockStyle") as Style); e.Column.HeaderTemplate = new DataTemplate(typeof(TextBlock)) {VisualTree = textBlock};