how to translate sign under appbar buttom

佐手、 提交于 2019-12-12 04:44:36

问题


Hello I want to localize text below standard 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>

I've tried in Resource filead add something like

ButtonId.AutomationProperties.Name = value

But it doesn not work. I get errors when app starts. How can I trasnlate this property ?


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



回答2:


You could try AutomationProperties.SetName(ButtonId, value);



来源:https://stackoverflow.com/questions/13572273/how-to-translate-sign-under-appbar-buttom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!