GridView tooltip on header

1 Answer 39 Views
GridView Styling
hhgm
Top achievements
Rank 1
Iron
hhgm asked on 29 Jul 2023, 04:28 PM

I am adding tooltip to my datagrid headers this way:

                <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}" 
                                            Width="40" 
                                            TextAlignment="Right">
                    <telerik:GridViewDataColumn.Header>
                        <TextBlock Text="#" 
                                   ToolTipService.ToolTip="Number of the match"/>
                    </telerik:GridViewDataColumn.Header>
                </telerik:GridViewDataColumn>

The problem is I also has this defined for my grid:

            <telerik:RadGridView.SortDescriptors>
                <telerik:SortDescriptor Member="StartDate" SortDirection="Ascending"/>
                <telerik:SortDescriptor Member="StartTime" SortDirection="Ascending"/>
                <telerik:SortDescriptor Member="PitchName" SortDirection="Ascending"/>
            </telerik:RadGridView.SortDescriptors>

With indirect styling, the header now does not change the text color and thus fade away behind the selected color of the header... how can I style the column to avoid this effect?

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 02 Aug 2023, 11:01 AM

Hello Hans,

If I understand correctly when sorting is applied to the column that has a TextBlock element set to its Header property, its foreground color is not changed? If this is the case, a new Style could be set to the TextBlock element from the Header property and its Foreground property could be changed via a DataTrigger.

The following code snippet shows this suggestion's implementation:

<telerik:GridViewDataColumn.Header>
    <TextBlock Text="#" ToolTipService.ToolTip="Number of the match">
        <TextBlock.Style>
            <Style TargetType="TextBlock">
                <Setter Property="Foreground" Value="black"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=telerik:GridViewHeaderCell}, Path=DataColumn.SortingState}" Value="None">
                        <Setter Property="Foreground" Value="White"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBlock.Style>
    </TextBlock>
</telerik:GridViewDataColumn.Header>

The produced result is as follows:

If this is not the case, could you share a bit more information about the observed behavior on your side?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView Styling
Asked by
hhgm
Top achievements
Rank 1
Iron
Answers by
Stenly
Telerik team
Share this question
or