views:

416

answers:

1

In our WPF application we show a data bound GridView, and one of the grid fields is a filter field which is combination of several sub-fields. In the grid, I show a simple string concatenation of the field, but I want the tooltip to show a formatted presentation of the filter. The formatted presentation might contain some or all of the filter fields.

I can freely change the class bound to the grid.

Can you recommend a way to bind the tooltip to the data, by adding some sort of a field, so it is nicely displayed, with multiple lines and indentation? I'd like to avoid specifying all the fields I need in the XAML and hide them based on the data, but I will probably do so if I don't come with a better approach. Another option might be to build the tooltip structure in code in the ToolTipOpening event. Do you have a better idea?

Thanks
splintor

A: 

I was having same scenario and was using DataTrigger in the Tooltip's Style to hide and show fields in tooltip based on their values.

viky
This caused too much mess, as I had to add many fields and maintain them. I ended up doing it in code, building the needed WPF objects according to needed content. I thought there is a way to specify XAML in code rather then creating explicit objects, but I didn't find an easy way to do it.
splintor