-1

I try to convert simple string and add markup string for example:

Value is: bla bla

into: Value is <Span Foreground="Red">bla bla</Span>

So i want to use MultiValueConverter and add simple converter (so far without any implementation):

public class StatusConverter : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }

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

Window.Resources:

    <my:StatusConverter x:Key="StatusConverterToColor"/>

Usage:

<TextBlock Text="{Binding Status, Converter={StaticResource StatusConverterToColor}}" />

But got this error:

{"Unable to cast object of type 'MyApplication.classes.StatusConverter' to type 'System.Windows.Data.IValueConverter'."}

What i am doing wrong ?

Nuz reel
  • 19
  • 3

1 Answers1

1

Change IMultiValueConverter to IValueConverter. Declaration should be

public class StatusConverter : IValueConverter
{ ... }
Eldar
  • 862
  • 9
  • 22
  • And with IValueConverter i will be able to change my string and add this markup ? – Nuz reel Dec 20 '15 at 13:57
  • Yes it should, as soon as provided real implementation inside `Convert` method instead of throwing `NotImplementedException` – Eldar Dec 20 '15 at 13:59