|
1 | 1 | # How to change the orientation of column header text in wpf treegrid? |
2 | | -This example illustrates how to change the orientation of column header text in wpf treegrid |
| 2 | + |
| 3 | +This example illustrates how to change the orientation of column header text in [WPF TreeGrid](https://www.syncfusion.com/wpf-controls/treegrid). |
| 4 | + |
| 5 | +Orientation of the `TreeGrid` column header text can be changed by editing the control template of the [TreeGridHeaderCell](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridHeaderCell.html) and applying `RotateTransform`. |
| 6 | + |
| 7 | + |
| 8 | +``` xml |
| 9 | +<Style TargetType="syncfusion:TreeGridHeaderCell"> |
| 10 | + <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}" /> |
| 11 | + <Setter Property="Foreground" Value="{StaticResource HeaderForegroundBrush}" /> |
| 12 | + <Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" /> |
| 13 | + <Setter Property="BorderThickness" Value="0,0,1,1" /> |
| 14 | + <Setter Property="HorizontalContentAlignment" Value="Center" /> |
| 15 | + <Setter Property="Padding" Value="5,3,5,3" /> |
| 16 | + <Setter Property="FontSize" Value="14" /> |
| 17 | + <Setter Property="FontWeight" Value="Normal" /> |
| 18 | + <Setter Property="IsTabStop" Value="False" /> |
| 19 | + <Setter Property="Template"> |
| 20 | + <Setter.Value> |
| 21 | + <ControlTemplate TargetType="syncfusion:TreeGridHeaderCell"> |
| 22 | + <Grid> |
| 23 | + <Grid.LayoutTransform> |
| 24 | + <RotateTransform Angle="90"/> |
| 25 | + </Grid.LayoutTransform> |
| 26 | + <Border x:Name="PART_FooterCellBorder" |
| 27 | + Background="{TemplateBinding Background}" |
| 28 | + BorderBrush="{TemplateBinding BorderBrush}" /> |
| 29 | + <Border x:Name="PART_HeaderCellBorder" |
| 30 | + Background="{TemplateBinding Background}" |
| 31 | + BorderBrush="{TemplateBinding BorderBrush}" |
| 32 | + BorderThickness="{TemplateBinding BorderThickness}" |
| 33 | + SnapsToDevicePixels="True"> |
| 34 | + <Grid Margin="{TemplateBinding Padding}" SnapsToDevicePixels="True"> |
| 35 | + <Grid.ColumnDefinitions> |
| 36 | + <ColumnDefinition Width="*" /> |
| 37 | + <ColumnDefinition Width="Auto" /> |
| 38 | + </Grid.ColumnDefinitions> |
| 39 | + <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
| 40 | + VerticalAlignment="Center" |
| 41 | + Focusable="False" /> |
| 42 | + <Grid x:Name="PART_SortButtonPresenter" |
| 43 | + Grid.Column="1" |
| 44 | + SnapsToDevicePixels="True"> |
| 45 | + <Grid.ColumnDefinitions> |
| 46 | + <ColumnDefinition Width="0" MinWidth="{Binding Path=SortDirection, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource sortDirectionToWidthConverter}}" /> |
| 47 | + <ColumnDefinition Width="*" /> |
| 48 | + </Grid.ColumnDefinitions> |
| 49 | + |
| 50 | + <Path Width="8.938" |
| 51 | + Height="8.138" |
| 52 | + HorizontalAlignment="Center" |
| 53 | + VerticalAlignment="Center" |
| 54 | + Data="F1M753.644,-13.0589L753.736,-12.9639 753.557,-12.7816 732.137,8.63641 732.137,29.7119 756.445,5.40851 764.094,-2.24384 764.275,-2.42352 771.834,5.1286 796.137,29.4372 796.137,8.36163 774.722,-13.0589 764.181,-23.5967 753.644,-13.0589z" |
| 55 | + Fill="{TemplateBinding Foreground}" |
| 56 | + SnapsToDevicePixels="True" |
| 57 | + Stretch="Fill" |
| 58 | + Visibility="{Binding Path=SortDirection, |
| 59 | + RelativeSource={RelativeSource TemplatedParent}, |
| 60 | + ConverterParameter=Ascending, |
| 61 | + Converter={StaticResource sortDirectionToVisibilityConverter}}"> |
| 62 | + <Path.RenderTransform> |
| 63 | + <TransformGroup> |
| 64 | + <TransformGroup.Children> |
| 65 | + <RotateTransform Angle="0" /> |
| 66 | + <ScaleTransform ScaleX="1" ScaleY="1" /> |
| 67 | + </TransformGroup.Children> |
| 68 | + </TransformGroup> |
| 69 | + </Path.RenderTransform> |
| 70 | + </Path> |
| 71 | + |
| 72 | + <Path Width="8.938" |
| 73 | + Height="8.138" |
| 74 | + HorizontalAlignment="Center" |
| 75 | + VerticalAlignment="Center" |
| 76 | + Data="F1M181.297,177.841L181.205,177.746 181.385,177.563 202.804,156.146 202.804,135.07 178.497,159.373 170.847,167.026 170.666,167.205 163.107,159.653 138.804,135.345 138.804,156.42 160.219,177.841 170.76,188.379 181.297,177.841z" |
| 77 | + Fill="{TemplateBinding Foreground}" |
| 78 | + SnapsToDevicePixels="True" |
| 79 | + Stretch="Fill" |
| 80 | + Visibility="{Binding Path=SortDirection, |
| 81 | + RelativeSource={RelativeSource TemplatedParent}, |
| 82 | + ConverterParameter=Decending, |
| 83 | + Converter={StaticResource sortDirectionToVisibilityConverter}}"> |
| 84 | + <Path.RenderTransform> |
| 85 | + <TransformGroup> |
| 86 | + <TransformGroup.Children> |
| 87 | + <RotateTransform Angle="0" /> |
| 88 | + <ScaleTransform ScaleX="1" ScaleY="1" /> |
| 89 | + </TransformGroup.Children> |
| 90 | + </TransformGroup> |
| 91 | + </Path.RenderTransform> |
| 92 | + </Path> |
| 93 | + |
| 94 | + <TextBlock Grid.Column="1" |
| 95 | + Margin="0,-4,0,0" |
| 96 | + VerticalAlignment="Center" |
| 97 | + FontSize="10" |
| 98 | + Foreground="{TemplateBinding Foreground}" |
| 99 | + SnapsToDevicePixels="True" |
| 100 | + Text="{TemplateBinding SortNumber}" |
| 101 | + Visibility="{TemplateBinding SortNumberVisibility}" /> |
| 102 | + |
| 103 | + </Grid> |
| 104 | + </Grid> |
| 105 | + </Border> |
| 106 | + </Grid> |
| 107 | + </ControlTemplate> |
| 108 | + </Setter.Value> |
| 109 | + </Setter> |
| 110 | +</Style> |
| 111 | +``` |
0 commit comments