Loc in code

Mar 14, 2013 at 12:12 PM
Edited Mar 14, 2013 at 12:26 PM
I have a main window that is based on a control template. Which means that I dont have xaml for the window itself (just the control template). So my options to change parameters of the window are either in the code or in the style.

As presented here: http://wpflocalizeextension.codeplex.com/discussions/434583 style does not work for some reason, so following code will fail (after changing the language):
<Style TargetType="{x:Type Windows:MainWindow}" BasedOn="{x:Null}">
        <Setter Property="Template" Value="{DynamicResource MainWindowControlTemplate}" />
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Title" Value="{lex:Loc Assembly:Dict:WindowTitle}"/>
So I would like to try code... In the window constructor I do something like that:
Title = ResourcesHelper.GetLocalisationString(Consts.MainWindowTitleResourceKey);
The method uses locExtension.ResolveLocalizedValue to get the value which works... However, when I change the language the title is not updated.

Do I have any other options?
Mar 14, 2013 at 12:57 PM
I think this is somehow a duplicate of this discussion:

does that help you?

Mar 14, 2013 at 1:17 PM
That was it! Thanks!
Mar 15, 2013 at 8:16 AM
You're welcome :)