We're developing a WPF & MVVM application that requires multi-language support. On each control with static text, we're using a converter to do a lookup for the appropriate word for the user's language.
However, this means that each control does not display any text. This causes some irritation for the UI developers at design-time. Is there any way to display design-time text?
For example:
<TextBlock>
<TextBlock.Text>
<Binding Converter="{StaticResource Translator}"
Path="Controller"
ConverterParameter="Search for" />
</TextBlock.Text>
</TextBlock>
How can I make this converter execute at design time to display the translated converter parameter?
First of all I would suggest that you use a markup extension for that. Then you markup would look something like this:
<TextBlock Text="{my:Localize Key=MyLabel, Default='The text you want to be displayed by default'}" .../>
The default text will also be displayed in Blend.
Second of all I don't see the problems with the converter approach as long as the converter returns a valid default text. In other words converters should be executed in design time as well as in run time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With