I want to add a Tooltip for the text in a column. If I specify the column name explicitly, this works:
<igDataGrid:TemplateColumn Key="Description" > <igDataGrid:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Height="14" Text="{Binding Description}" ToolTipService.ToolTip="{Binding Description}" > </TextBlock> </DataTemplate> </igDataGrid:TemplateColumn.ItemTemplate></igDataGrid:TemplateColumn>
But, I'd like to define the template once as a resource and use it for any column - is there any way to avoid the hard-coded binding ("Description" in this case)? Possibly by referencing the Key of the ItemTemplate somehow?
Or is there a way to do this with the TextColumn, or a Style? I've tried several ways unsuccessfully.
Thanks,Keith
Hi Keith,
There isn't really a way to create TemplateColumns generically like that.
Although Tooltips are something we are looking into implementing in the XamWebGrid. If you could provide more information on what you're looking to have in this feature, we'd love to hear about it.
-SteveZ
Thanks Steve. My use case is displaying a description field that has multiple line breaks in it. This makes my row heights pretty large by default. I used a Style with the TextColumn to set the height, then was hoping to bind a ToolTip so users could hover over the field to see the full text. But you can't do that with a Style. So, I switched to the DataTemplate. Which works if I hardcode the field name in the template, I was just hoping to be able to resuse the template, rather than having to create one for Description, one for Notes, etc, etc.
Ideally the column templates would be like the GroupByItemTemplate. There you have access to Value which gives you the value being grouped on. With ColumnTemplate you get the row's DataContext which is nice, but would also be nice if you had Value which gave you access to the DataContext's value for the Key for the column. I tried with {Binding Key}, {Binding Value}, etc, but nothing I could think of worked. But being able to use {Binding Value} would allow you to reuse templates a lot more efficiently.
Thanks
A TextColumn is not a FrameworkElement, as Column's aren't visual.
Currently the only way to get tooltips, until we add the feature, is to use a TemplateColumn and put the ToolTipService.Tooltip on an element in your DataTemplate.
when i try to use it in a text column it throws exceptions
this: <igGrid:TextColumn Key="Quantity" ToolTipService.ToolTip="{Binding LineLabel}"
Throws: AG_E_PARSER_PROPERTY_NOT_FOUND [Line: 540 Position: 86]
This: <igGrid:TextColumn Key="Quantity" ToolTipService.ToolTip="TEst TOOL"
Throws: "AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 540 Position: 86]"
when i put it in a Templated Column it works??
Hard-coding works. But, I need it to be bound to the specific property on the data context for the row that the column represents.
does this not work in a TextColumn?
ToolTipService.ToolTip
="qqqqqqq"