Reputation: 21
My code in MainPage.cs
ApplicationLanguages.PrimaryLanguageOverride = "ja-jp";
XAML
<Button content="Click" Click="Button_Click" />
after this i've opened dialog with my code
private async void Button_Click(object sender, RoutedEventArgs e)
{
{
testDialog dialog = new testDialog();
await dialog.ShowAsync();
}
}
My testDialog's XAML code
<TextBlock x:Uid="TestTextBlock" />
i've define the language's text in Resources.resw file, it worked fine if i put textblock in current MainPage but when i put it in dialog the textblock's text doesn't change, It only change after i reset the application. Any ideas how can i fix this guys ?'
Upvotes: 0
Views: 322
Reputation: 367
Setting new language:
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "ja-jp";
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset();
Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset();
Reload Current page:
private bool Reload(object param = null)
{
var type = Frame.CurrentSourcePageType;
try
{
return Frame.Navigate(type, param);
}
finally
{
Frame.BackStack.Remove(Frame.BackStack.Last());
}
}
Also you can use Frame.Navigate(this.GetType());
for refreshing current page UI.
please take a look at this post for more information: Dynamically change the language of a universal app
Upvotes: 1