RichTextBlock,Paragraph,Hyperlink ......和全球化

时间:2014-12-26 21:39:22

标签: xaml windows-phone-8.1 globalization

在Windows Phone 8.1中,您可以使用不同的语言使用属性" x:Uid"一个元素,如果我这样做

<textblock x:Uid="string1"/>

并在我写的资源文件中

string1.Text: sentence in english

然后&#34;英语句子&#34; &#34;写的&#34;在textblock的Text属性中。对于按钮,将是string1.Content。

但是我有一个问题,我正在使用RichTextBlock,里面有Paragraph和Hyperlink,我可以使用x:Uid但是...要使用哪个属性?他们没有文字或内容属性,所以...我怎样才能全局化这些元素?

谢谢。

1 个答案:

答案 0 :(得分:3)

段落和超链接是集合。实际文本来自内部的Run,而Run有Text属性。如果显式而不是隐式设置运行,则可以将x:Uid添加到其Text属性:

的Xaml:

<Hyperlink>
    <Run x:Uid="hlink" Text="http://microsoft.com" />
</Hyperlink>

Resources.resw:

<data name="hlink.Text" xml:space="preserve">
    <value>http://stackoverflow.com</value>
</data>

显示的超链接将从资源文件中提取stackoverflow URL。