我创建了一个简单的转换器来连接我的WPF应用程序中四个TextBoxes的文本。
以下是转换器:
public class FourString:IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return string.Format("{0}{1}{2}{3}", values[0], values[1], values[2], values[3]);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return new object[] { };
}
}在Xaml中,我使用以下代码:
<local:FourString x:Key="converter"/>
<TextBox Grid.ColumnSpan="4" Margin="95,7.5,71.25,3.75" Name="CodeBoatTxt" >
<TextBox.Text>
<MultiBinding Converter="{StaticResource converter}" >
<Binding ElementName="CountryStringaTxt" Path="Text" />
<Binding ElementName="CityStringaTxt" Path="Text" />
<Binding ElementName="ServiceStringaTxt" Path="Text" />
<Binding ElementName="DurationStringaTxt" Path="Text" />
</MultiBinding>
</TextBox.Text>
</TextBox>在调试时,此错误出现在CodeBoatTxt文本框中:"DependecyProperty.UnsetValue“。
我的转换器出了什么问题?
发布于 2009-08-25 09:04:06
当Binding有效但尚未设置其值时,会将DependencyProperty.UnsetValue传递给转换器。我会单独检查组成您的MultiBinding的Binding,并确保它们是正确的。
https://stackoverflow.com/questions/1326940
复制相似问题