2012-11-26 29 views
0

你好,我要本地化低于标准AddAppBarButton如何appbar BUTTOM

<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> 

我在尝试资源添加filead类似

ButtonId.AutomationProperties.Name = value 

文本翻译下的迹象,但它不无法正常工作。我在应用启动时遇到错误。我怎样才能分析这个属性?

回答

1

为什么不是put the translation strings in resource files并让XAML解析器完成这项工作?

您需要在项目中创建与本地名称匹配的文件夹,并在其中放置resw文件,例如sl-SI\Resources.resw

添加x:Uid属性XAML元素给它们命名:

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

现在只是名称的资源字符串适当地使XAML解析器会发现它们。该模式是UidName.PropertyName,例如, Button.Content。在AppBar按钮的情况下,由于附加属性,语法稍微复杂一点:

AppBarButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name 
+0

正如我写的。我正在这样做。我有Resources.resw文件,但我不知道AutomationProperties的语法。我会尽快检查并让你知道 – Fixus

+0

这个更复杂的语法就是我正在寻找的。谢谢 – Fixus

0

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