Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 Datagrid Header Tooltip
3 replies. Latest Post by Zachary D. on July 9, 2009.
(0)
Zachary D.
Member
77 points
187 Posts
07-07-2009 1:45 PM |
What is the best way to add a tooltip to a datagrid header in SL 3?
The tooltips need to be dynamic
TomBeeby
Participant
1151 points
188 Posts
07-07-2009 11:35 PM |
To start with, do something like this:
<data:DataGrid> <data:DataGrid.Columns> <data:DataGridTextColumn Header="My Header"> <data:DataGridTextColumn.HeaderStyle> <Style TargetType="dataprimitives:DataGridColumnHeader"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <ContentControl Content="{Binding}"> <ToolTipService.ToolTip> <ToolTip Content="My Tooltip"></ToolTip> </ToolTipService.ToolTip> </ContentControl> </DataTemplate> </Setter.Value> </Setter> </Style> </data:DataGridTextColumn.HeaderStyle> </data:DataGridTextColumn> </data:DataGrid.Columns> </data:DataGrid>
You'll need to add this namespace declaration too
xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
As far making it dynamic, i'm not sure what you mean by that.. you could bind the text of the tooltip to some value, or even handle the opened event of the Tooltip, grab the tooltip's data context and then based on that decide what to put in the tooltip.
07-09-2009 11:18 AM |
The problem I am running into here is that this takes away the abilty to sort the datagrid when the column is clicked on
07-09-2009 11:26 AM |
actually sorting does still work... thanks for the help