localization - 在 UWP Style Setter 中使用字符串资源

标签 localization uwp uwp-xaml multilingual-app-toolkit

我正在将一个应用程序从 Windows 8 迁移到 UWP。该应用程序使用字符串资源进行本地化。 在 Windows 8 中,我曾经这样做来本地化 AppBar 按钮:

<Style x:Key="SkipAheadAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="SkipAheadAppBarButton"/>
    <Setter x:Uid="Step" Property="AutomationProperties.Name" Value=".skip"/>
    <Setter Property="Content" Value="&#xE101;"/>
</Style>

然后我会得到一个字符串“Step.Value”。由于某些原因,这在 Visual Studio 2017 中的 UWP 项目中不起作用。按钮显示“.skip”而不是 Resources.resw 中 Step.Value 的实际值。

更简单 <Run x:Uid="App" Text=".Rob"/>工作没有任何问题。

最佳答案

我们不能使用 x:UidSetter .

Use x:Uid to identify an object element in your XAML. Typically this object element is an instance of a control class or other element that is displayed in a UI.

更多信息请引用x:Uid directive的备注.

您应该能够添加 x:UidButton .

例如:

<Button  x:Uid="MyButton" AutomationProperties.Name="AddToIndexButton" Content="Button"></Button>

您应该能够设置 MyButton.AutomationProperties.NameNameYourValueValue Resources.resw 的。

我还测试了 <Run x:Uid="App" Text=".Rob"/> ,它会抛出异常。如果你可以在 UWP 中使用它,你能给我们一个示例吗?

关于localization - 在 UWP Style Setter 中使用字符串资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44092881/

相关文章:

localization - l10n '.arb'文件格式

c# - 从源代码管理丢失后如何生成新的 .pfx 文件?

c# - UWP 应用程序发布编译中的 System.TimeZoneNotFoundException

xaml - XAML 中数据模板的条件呈现

xaml - 将 MenuFlyout 添加到 RichEditBox UWP

javascript - Phonegap 应用程序翻译

javascript - ASP.NET 阿拉伯语文本 - 句号错误地出现在句首

c# - 缺少 XmlSchemaSet UWP

c# - 如何在 UWP XAML/C# 中更改滚动查看器的滚动量?

ios - iOS 是否查找特定于区域的 .lproj 目录(例如 en_US.lproj)?