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