Assume I have SomeExtension MarkupExtension. Does anyone know how to assign it to a property from C# code?
That is for example in XAML I have:
<TextBlock Text="{l:Translate LocalizedByMarkupExtension}" />
I want to do the same using C# code.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your example, your TranslateExtension would need to implement a constructor that takes a single parameter. So you’d just need to pass the value into the constructor like so:
The parameter may be converted using an associated TypeConverter or a special Xaml value converter. But if you are simply passing strings, then the above should work.
Then you’d call ProvideValue method to get the result.