我有以下 XAML 文本框:
<TextBox x:Name="TextBoxShippingLabel" Margin="0,10,-2,2" TextWrapping="Wrap">
<TextBox.Text>
<MultiBinding StringFormat="{}{0} {1}
{2}
{3}
{4}
{5}
{6} {7}" Converter="{local:ShippingLabelConverter}">
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[FirstName]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[Surname]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[Department]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[Organisation]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[Street]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[Suburb]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[State]" />
<Binding ElementName="dataGridOutstandingOrders" Path="SelectedItem[Postcode]" />
</MultiBinding>
</TextBox.Text>
</TextBox>
我正在尝试将其绑定到一个转换器,它代表以下内容:
namespace CIC.OrderProcessor
{
public class ShippingLabelConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var output = new StringBuilder();
foreach (var param in values.Cast<string>().Where(param => param != "None"))
{
output.Append(param);
}
return output.ToString();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
但是 Visual Studio 告诉我以下内容:
名称空间“clr-namespace:CIC.OrderProcessor”中不存在名称“ShippingLabelConverter”。
标记扩展类型无效:预期类型为“IMultiValueConverter”,实际类型为“ShippingLabelConverter”
我已经检查了我的转换器类的命名空间,它绝对是正确的。它还继承了“IMultiValueConvterer”类型,所以我有点不确定从哪里开始——错误看起来应该很明显,但我看不到我应该做的任何改变。
额外的信息
我的 XAML 中本地命名空间的声明如下:
<Window x:Class="CIC.OrderProcessor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CIC.OrderProcessor"