UWP如何刷新文本而无需重新导航

时间:2017-04-08 11:49:34

标签: c# uwp win-universal-app multilingual

我有一个多语言应用程序,允许用户使用下拉菜单切换语言。它运行正常,但切换语言时速度太慢,因为我需要重新导航到当前帧。这是因为我需要重新加载我的产品(这需要一些时间)。

这是我的代码:

System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(MainForm));
foreach (Control ctl in this.Controls)
{
    rm.ApplyResources(ctl, ctl.Name);
}

我的问题是,有没有办法强制所有 x:Uid 的组件从资源文件重新加载(例如 Strings / en-US / Resources.resw )没有调用 Frame.Navigate()

在WinForm中,我可以执行以下操作:

{{1}}

UWP中是否有相应的内容?或者有更好的方法来解决我的问题吗?

由于

1 个答案:

答案 0 :(得分:1)

我使用this pattern from the documentation使用this sample来通知我的数据发生了变化。如果我没有错,你想要在更改时通知xaml元素的内容(例如Text)。然后你需要使用绑定。

希望有所帮助!