Reputation: 3703
I have a DataGrid
with list of DataRows as its ItemSource
. I want each cell to have a ToolTip
of 2 DataCell
values, so I'm using a MultiBinding on the ToolTipService.ToolTip
object. The Converter returns the currect data (as a string), but the ToolTip
shows the system name of the TextBlock
. I'm trying to do what is in here, but the result is the same: it returns the TextBlock
system name but not the value that I'm expecting.
Any idea what I'm missing?
Thanks in advance.
The XAML:
<TextBlock Padding="5,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center"
Text="{Binding Path=[1][cell_value], Converter={StaticResource Converter1}}" FlowDirection="LeftToRight">
<ToolTipService.ToolTip>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="F {0}{1}" Converter="{StaticResource Converter2}">
<Binding Path="[1][updted_by]" />
<Binding Path="[1][v_date]" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</ToolTipService.ToolTip>
The converter:
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
int v = 0;
if (values[0] == null)
return string.Empty;
int.TryParse(values[0].ToString(), out v);
if (v < 1)
return string.Empty;
string result1 = string.Empty;
string result2 = string.Empty;
result1 = ManageBL.GetUserNameStringById((int)values[0]);
// now convert the date
if (values[1] == null || values[1] == DBNull.Value)
return Binding.DoNothing;
DateTime dt = DateTime.MinValue;
DateTime.TryParse(values[1].ToString(), out dt);
if (dt == DateTime.MinValue || dt == DateTime.Parse("01/01/1900"))
{
return null;
}
result2 = dt.ToShortDateString();
return result1 + result2;
}
catch (Exception)
{
return Binding.DoNothing;
}
}
Upvotes: 1
Views: 593
Reputation: 11221
Try setting the MultiBinding as the Tooltip value directly
<ToolTipService.ToolTip>
<MultiBinding StringFormat="F {0}{1}" Converter="{StaticResource Converter2}">
<Binding Path="[1][updted_by]" />
<Binding Path="[1][v_date]" />
</MultiBinding>
</ToolTipService.ToolTip>
As per reference.
Upvotes: 2