This is a migrated thread and some comments may be shown as answers.

How rotate column header text of GridViewDataColumn

5 Answers 982 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 1
Veteran
Anton asked on 28 Oct 2020, 03:14 AM

Hello.

Help me with next problem, how i can rotate column header text of GridViewDataColumn on 90 degree?

I am create columns in programm code

column = new GridViewDataColumn
{
                   ColumnGroupName = args.ColumnDef.ColumnGroupName,

                    DataMemberBinding = new Binding(args.ColumnDef.Member)
                    {
                        Mode = BindingMode.TwoWay,
                        UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                    },
                    IsReadOnlyBinding = new Binding(args.ColumnDef.IsReadOnlyMember)
                    {
                        Converter = new NullToBooleanConverter {IsInverted = true}
                    },

                    Header = args.ColumnDef.Header,
                    HeaderTextWrapping = TextWrapping.Wrap,
                    IsVisible = true,
};

 

Also, how i can add borders to cells?

5 Answers, 1 is accepted

Sort by
0
Anton
Top achievements
Rank 1
Veteran
answered on 29 Oct 2020, 04:08 AM

I find that i can do this in 'Setting a Column's HeaderCellStyle' (https://docs.telerik.com/devtools/wpf/controls/radgridview/styles-and-templates/styling-column-headers), but i got suddenly result, all header cell content rotate on setted angle:

<Style BasedOn="{StaticResource GridViewHeaderCellStyle}" TargetType="telerik:GridViewHeaderCell">
                <Setter Property="ToolTipService.ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Content.Text, Mode=OneWay}" />
                <Setter Property="telerik:RadContextMenu.ContextMenu" Value="{StaticResource ColumnHeaderContextMenu}" />
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="Foreground" Value="Red"/>
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <RotateTransform Angle="90"/>
                    </Setter.Value>
                </Setter>
        </Style>

 

What i can do?

0
Anton
Top achievements
Rank 1
Veteran
answered on 29 Oct 2020, 04:42 AM

also, i am create 

 <Style BasedOn="{StaticResource GridViewGroupHeaderCell}" TargetType="telerik:GridViewGroupHeaderCell">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="Background" Value="Aqua"/>
            <Setter Property="FontSize" Value="20"></Setter>
        </Style>

but this don't work...why?

0
Anton
Top achievements
Rank 1
Veteran
answered on 29 Oct 2020, 07:32 AM
[quote]Anton said:

also, i am create 

 <Style BasedOn="{StaticResource GridViewGroupHeaderCell}" TargetType="telerik:GridViewGroupHeaderCell">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="Background" Value="Aqua"/>
            <Setter Property="FontSize" Value="20"></Setter>
        </Style>

but this don't work...why?

[/quote]

understand, need

<Style TargetType="telerik:CommonColumnHeader">

0
Dinko | Tech Support Engineer
Telerik team
answered on 30 Oct 2020, 10:22 AM

Hi Anton,

Thank you for the provided code snippets.

To rotate the columns' header, you need to extract and edit the default template of the GridViewHeaderCell.  In the extracted template, you can rotate the Grid named PART_HeaderCellGrid to the specified angle. To fix the filter drop-down position, you will need to rotate the filter icon (grid:FilteringDropDown x:Name="PART_DistinctFilterControl") to open its dropdown content vertically. There is Editing Control Templates help article in our documentation, which describes how you can get the default template of the controls. I have prepared an example for you that demonstrates this approach.

The attached project uses XAML binaries, and the extracted template is based on the default one (Office_Black).

As for your second scenario, I am assuming that you have found a solution. Correct me if I am wrong.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Anton
Top achievements
Rank 1
Veteran
answered on 02 Nov 2020, 04:31 AM
[quote]Dinko said:

Hi Anton,

Thank you for the provided code snippets.

To rotate the columns' header, you need to extract and edit the default template of the GridViewHeaderCell.  In the extracted template, you can rotate the Grid named PART_HeaderCellGrid to the specified angle. To fix the filter drop-down position, you will need to rotate the filter icon (grid:FilteringDropDown x:Name="PART_DistinctFilterControl") to open its dropdown content vertically. There is Editing Control Templates help article in our documentation, which describes how you can get the default template of the controls. I have prepared an example for you that demonstrates this approach.

The attached project uses XAML binaries, and the extracted template is based on the default one (Office_Black).

As for your second scenario, I am assuming that you have found a solution. Correct me if I am wrong.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products, quickly just got a fresh new look + new and improved content, including a brand new Blazor course! Check it out at https://learn.telerik.com/.

[/quote]

 

Thank you, i'll see

Tags
GridView
Asked by
Anton
Top achievements
Rank 1
Veteran
Answers by
Anton
Top achievements
Rank 1
Veteran
Dinko | Tech Support Engineer
Telerik team
Share this question
or