我想綁定兩個文本來源在我的數據網格的工具。 所以這是XAML:如何在dataGridCell工具提示上設置多重綁定?
<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
<Style.Setters>
<!--Some other setter properties-->
<Setter Property="ToolTip">
<Setter.Value>
<MultiBinding Converter="{StaticResource TooltipMultiValueConverter}" UpdateSourceTrigger="PropertyChanged">
<Binding Path="{Binding Path=ControlValue, Converter = {StaticResource FloatToString}, ConverterParameter=F2}"></Binding>
<Binding Path="{Binding Path=StatusText}"></Binding>
</MultiBinding>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
而在C#中相應的轉換器:
class TooltipMultiValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return String.Concat(values[0], " ", values[1]);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
但我的應用程序崩潰,因爲有下列錯誤每次:
'Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.'
我沒有想法我應該提供什麼價值?它的工作原理只是罰款,如果我不使用multibinding,並提供一個單一的文本源作爲一種價值...
如果這是你確切的代碼 - 你忘了實際上是爲你multibinding集轉換。 '' –
Evk
忘了複製它,我更新了轉換器,因爲它在我的代碼中。 – Vrankela
然後,您需要查看您提供的異常的InnerException - 此處有更多信息。 – Evk