在 AppResources 中使用字符串

Rid*_*ulu 4 c# windows-phone windows-phone-8.1

我正在LocalizedResources为我的 WP 8.1 应用程序进行本地化。但是如果我使用这样的代码:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    string xyz = string.Empty;
    NavigationContext.QueryString.TryGetValue("znam", out xyz);
    tekstZnamenitosti.Text = AppResources.tekstTrsat;
}
Run Code Online (Sandbox Code Playgroud)

那么我将不得不有很多 if 语句来检查每个znamenitost. 有没有办法使用

tekstZnamenitosti.Text = AppResources.xyz;
Run Code Online (Sandbox Code Playgroud)

其中 xyz 是我之前创建的字符串,其中是从我导航的页面传递的值。

Chr*_*hao 5

您可以AppResources使用ResourceManager获取值:

tekstZnamenitosti.Text = AppResources.ResourceManager.GetString("xyz");
Run Code Online (Sandbox Code Playgroud)