Reputation: 85
I have a DataGrid in WPF application showing one column. I want to have a tootip that shows all data from each row. It's something like this (this works):
<DataGridTextColumn Header="ScreenName" Binding="{Binding Name}" >
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip" Value="{Binding Name}" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
If I change the Binding to another property (like Value="{Binding Age}") also works, shows the age in tooltip. In my Setter, how do I bind all the data to show in a single tooltip? Name, Age, City, Birthday, MoreData...
Upvotes: 2
Views: 653
Reputation: 2123
You can also use MultiBinding:
<Setter.Value>
<MultiBinding StringFormat="{0} {1} {2}">
<Binding Age />
<Binding Name />
<Binding City />
</MultiBinding>
</Setter.Value>
Upvotes: 1
Reputation: 18580
You will have to use the converter
<Setter Property="ToolTip" Value="{Binding Converter={StaticResource MyConverter}" />
public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//Create your string here from properties
return tooltiptext;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value;
}
}
Upvotes: 1