views:

22

answers:

1

We have a WPF application that is loading a usercontrol at runtime from the deployed .XAML file (customer requirement - they want to be able to replace the views entirely).

We would like to localize strings in this XAML file. All .resx file based WPF localization approaches I have found on the web seem to require recompilation when the localized values are changed.

How to localize a dynamically loaded XAML usercontrol without needing to recompile the resources?

+1  A: 

This solution seems to provide a markup extensiion that manages localization loaded from XML files.

Syntax:

<TextBlock loc:Translate.Uid="3"
    Text="{loc:Translate}"
    Background="{loc:Translate}"
    Width="{loc:Translate}"
    Height="{loc:Translate}" FontSize="18" 
/>

It also supports on the fly language selection (no need to reopen the window).

Marek