我在XAML中有这个var dialog = new MessageDialog("Error", "Error: Example"); await dialog.ShowAsync();,我翻译成这样:x:Uid=“示例”,我想翻译您在messagedialog中显示的消息--如何在C#中进行翻译?
发布于 2017-03-06 11:07:31
您可以使用ResourceLoader类:
string localizedString = ResourceLoader.GetForCurrentView().GetString("<Key from resw>");可以将一个可选字符串传递给GetForCurrentView方法,在该方法中可以指定resw文件的名称。
更新
GetString方法返回一个字符串对象,您可以使用它来创建MessageDialog。
var loader = ResourceLoader.GetForCurrentView();
string title = loader.GetString("example_Title");
string content = loader.GetString("example_Content");
var dialog = new MessageDialog(content, title);
await dialog.ShowAsync();更新2
resw文件中的键不能包含“.”因为某种原因。也许是因为x:Uid的行为..。
https://stackoverflow.com/questions/42623866
复制相似问题