GridView tooltip on header

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

I am adding tooltip to my datagrid headers this way:

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

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

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

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
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:

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

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?

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.

GridView Styling
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question