How to add tooltip text to Gridview column header, WPF VS2010

Here is my grid i to give an explanation of the heading "RED.BROJ" when the mouse is over this heading to show expl. text.

<ListView.View> <GridView> <GridViewColumn Width="50" Header="d.ј" DisplayMemberBinding="{Binding Path=RedenBroj}"> </GridViewColumn> 
+6
source share
2 answers

You can do it:

 <GridViewColumn Width="50" DisplayMemberBinding="{Binding Path=RedenBroj}"> <GridViewColumn.Header> <TextBlock Text=".ј" ToolTip="Your explanation" /> </GridViewColumn.Header> </GridViewColumn> 
+6
source

A bit late answer, but you can add a tooltip without losing the ability to drag and drop columns to reorder them by following these steps:

 <GridViewColumn Width="50" Header="d.ј" DisplayMemberBinding="{Binding Path=RedenBroj}"> <GridViewColumn.HeaderContainerStyle> <Style> <Setter Property="Control.ToolTip" Value="Tool tip content"/> </Style> </GridViewColumn.HeaderContainerStyle> </GridViewColumn> 

Update: a shorter option thanks to LPL

Further update: I wanted to be able to have all the columns tooltips matching their headings (since some columns were too narrow to show the entire heading):

 <ListView.View> <GridView> <GridView.ColumnHeaderContainerStyle> <Style TargetType="GridViewColumnHeader"> <Setter Property="ToolTip" Value="{Binding Content, RelativeSource={RelativeSource Self}}"/> </Style> </GridView.ColumnHeaderContainerStyle> <GridViewColumn DisplayMemberBinding="{Binding A}" Header="A"/> <GridViewColumn DisplayMemberBinding="{Binding B}" Header="B"/> <GridViewColumn DisplayMemberBinding="{Binding C}" Header="C"/> </GridView> </ListView> 
+5
source

Source: https://habr.com/ru/post/918745/


All Articles