Codingo Codingo - 1 year ago 91
C# Question

Multi-value converter not accesssable

I have the following XAML textbox:

<TextBox x:Name="TextBoxShippingLabel" Margin="0,10,-2,2" TextWrapping="Wrap">
<MultiBinding StringFormat="{}{0} {1}&#x0a;{2}&#x0a;{3}&#x0a;{4}&#x0a;{5}&#x0a;{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]" />

I'm trying to bind this to a converter, that represents the following:

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"))

return output.ToString();

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
throw new NotImplementedException();

However Visual Studio is telling me the following:

The name "ShippingLabelConverter" does not exist in the namespace

Invalid markup extension type: expected type is
'IMultiValueConverter', actual type is 'ShippingLabelConverter'

I've checked the namespace for my converter class and it's definitely correct. It's also inheriting the type 'IMultiValueConvterer' so I'm a bit unsure where to go from here - the errors seem like they should be obvious but I can't see any changes I should be making.

Extra Information

The declaration of the local namespace from my XAML is as follows:

<Window x:Class="CIC.OrderProcessor.MainWindow"

Answer Source

Essentially you need to create an instance of the converter before you can use it:

    <local:ShippingLabelConverter x:Key="shippingLabelConverter" />


<MultiBinding StringFormat="{}{0} {1}&#x0a;{2}&#x0a;{3}&#x0a;{4}&#x0a;{5}&#x0a;{6} {7}" Converter="{StaticResource shippingLabelConverter}">

Alternative: There is an alternative which is to implement another interface "MarkupExtension" so the converter knows how to provide an instance of itself. Check out this article:

public class DummyConverter : MarkupExtension, IValueConverter
    private static DummyConverter _converter = null;
    public override object ProvideValue(IServiceProvider serviceProvider)
        if (_converter == null)
            _converter = new DummyConverter();
        return _converter;
    #region IValueConverter Members
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download