0

您好,我想在标准 AddAppBarButton 下方本地化文本

<Style x:Key="AddAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="AddAppBarButton"/>
    <Setter Property="AutomationProperties.Name" Value="Add"/>
    <Setter Property="Content" Value="&#xE109;"/>
</Style>

我试过在资源文件中添加类似

ButtonId.AutomationProperties.Name = value

但它不起作用。应用程序启动时出现错误。我怎样才能翻译这个属性?

4

2 回答 2

1

Why not put the translation strings in resource files and let XAML parser do the work?

You need to create a folder in your project matching the locale name and put a resw file inside it, e.g sl-SI\Resources.resw.

Add x:Uid attribute to XAML elements to name them:

<Button x:Uid="AppBarButton" Style="{StaticResource AddAppBarButtonStyle}" />

Now just name the resource strings appropriately so that the XAML parser will find them. The pattern is UidName.PropertyName, e.g. Button.Content. In the case of AppBar buttons the syntax is a little more complex because of attached properties:

AppBarButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
于 2012-11-27T05:54:22.050 回答
0

你可以试试 AutomationProperties.SetName(ButtonId, value);

于 2012-11-26T20:40:47.010 回答