Open raozhihao opened 3 years ago
When i reference
@raozhihao Please provide a sample app. Thx
This is code
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--if not reference ,right click can change language-->
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />-->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Theme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<mah:MetroWindow x:Class="MahLang.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<StackPanel>
<TextBox Text="Pelase mouse right clik ,look this language" />
<Button Content="Change Language"
Click="Button_Click" />
<TextBlock Text="zh-CN"
x:Name="langTxt" />
</StackPanel>
</mah:MetroWindow>
bool useZhCN = false;
private void Button_Click(object sender, RoutedEventArgs e)
{
string cultureStr = "zh-CN";
if (!useZhCN)
cultureStr = "en-US";
this.langTxt.Text = cultureStr;
Application.Current.Dispatcher.Thread.CurrentUICulture = new CultureInfo(cultureStr);
}
I want to set Application.Current.Dispatcher.Thread.CurrentUICulture
To localize, but not ,if I reference
When, the right-click menu of TextBox on my form is Chinese language, and set Application.Current.Dispatcher.Thread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
At this time, the right-click menu of TextBox is not changed to English language
If I don't reference it, I can change it