UWP MVVM:更改语言后刷新页面 [英] UWP MVVM: refresh page after change of language
本文介绍了UWP MVVM:更改语言后刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的视图模型中有一些代码会更改应用程序语言,然后更改某些控件上的文本.
I have some code in my view model which changes the application language, which then changes the text on some of the controls.
这是DashboardViewModel
,仪表盘页面的数据上下文设置为:
This is the DashboardViewModel
, which the Dashboard Page's data context is set to:
ApplicationLanguages.PrimaryLanguageOverride = languageCode;
ResourceContext.GetForCurrentView().Reset();
ResourceContext.GetForViewIndependentUse().Reset();
NavigationService.Navigate(typeof(DashboardPage));
使用 NavigationService.Navigate(typeof(DashboardPage));
我试图强制页面刷新,但没有成功.我该怎么做?
With NavigationService.Navigate(typeof(DashboardPage));
I tried to force the page to refresh, with no success. How would I do this?
推荐答案
这条线很适合我.
await Task.Delay(100);
Frame.Navigate(this.GetType());
这篇关于UWP MVVM:更改语言后刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文