[ACCEPTED]-programmatically using a value converter in C# in Silverlight-silverlight

Accepted answer
Score: 15

If you just want to call the converter explicitly 3 in the code behind, just use the converter 2 class just like any other class and call 1 its Convert() methos with appropriate parameters

YourConverter conv = new YourConverter();
Score: 9

I personally add a static method to the 4 converter like so:

public static object Convert(object value)
    return new MyConverter().Convert(value, null, null, CultureInfo.CurrentCulture);

You can then use this 3 in code like so:


You can even change the 2 return type and cast the result before returning 1 to make usage easier.

More Related questions