Why cannot use same approach for Windows Phone application? There is many reasons:
- Windows Phone don't support satellite assemblies.
- Windows Phone don't care about xml:lang
- MergedDictionary degrade preformance
So try to use another approach. Define control, Button for example and apply default style
- <Button x:Name="MyStyledButton" Content="Button" Style="{StaticResource MyButton}"/>
Then put general style in App.xaml
- <Style x:Key="MyButton" TargetType="Button">
- <Setter Property="Background" Value="#303030"></Setter>
- <Setter Property="BorderThickness" Value="0"></Setter>
- </Style>
Another bug in Windows Phone 7 that attribute BasedOn not supported, so we have to copy whole style to derived. Next step change name, adding -[lang code] to x:Key of style. So 'MyButton' will be 'MyButton-de' for example.
- <Style x:Key="MyButton-ru" TargetType="Button">
- <Setter Property="Background" Value="#FF8080"></Setter>
- <Setter Property="BorderThickness" Value="1"></Setter>
- </Style>
Next we'll add runtime code for loading language dependent styles.
- string lang = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
- // load localized style
- Style style = (Style)App.Current.Resources["MyButton-" + lang];
- if (style != null)
- {
- MyButton.Style = style;
- }
In runtime we determine current UI language and try to load altered style. If found, apply new style, if not - hardcoded style will be used.
Thanks for your good website and for sharing your experiences.
ReplyDeletePhone Solutions
Ernest, have you tried the translation platform https://poeditor.com to manage your Windows localization projects? If not, I think you may find it helpful, so give it a look.
ReplyDeleteThis latest Bill Gate's innovation was released over the Christmas holiday of 2010. oukitel
ReplyDeleteThe cost of roaming is still high. However, contemporary travelers may now afford to stay in contact with loved ones while traveling. Of course, they still carry their smartphones, but there is a significant change: they purchase an overseas SIM card directly. Roaming IoT SIM Card
ReplyDelete