Programmatically using a value converter in C # in Silverlight

I have a Silverlight C # application. In this application, I have defined the value converter that I use in XAML. I came across a situation where I need to programmatically use this value converter in my code. My question is: how do I do this? In XAML, I use a value converter as follows:

<TextBlock x:Name="myTextBlock" Text="{Binding Mode=OneWay, Path=FirstName, Converter={StaticResource myConverter}, ConverterParameter=NotSet}" />

How to use this converter in my code?

Thank!

+3
source share
2 answers

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

YourConverter conv = new YourConverter();
conv.Convert(...)
+11
source

Source: https://habr.com/ru/post/1789534/


All Articles