如何在appbar按钮下翻译符号 [英] how to translate sign under appbar buttom

查看:69
本文介绍了如何在appbar按钮下翻译符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想将文本本地化为标准的AddAppBarButton

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 ?

推荐答案

为什么不将翻译字符串放入资源文件中,然后让XAML解析器完成工作?

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

您需要在项目中创建一个与语言环境名称匹配的文件夹,然后在其中放入一个resw文件,例如sl-SI\Resources.resw.

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.

在XAML元素中添加x:Uid属性以对其进行命名:

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

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

现在只需适当地命名资源字符串,以便XAML解析器可以找到它们.模式为UidName.PropertyName,例如Button.Content.对于AppBar按钮,由于附加属性,语法会稍微复杂一些:

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

这篇关于如何在appbar按钮下翻译符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆