Windows 8.1 新增控件之 Hyperlink

Hyperlink 控件应该不用过多介绍大家肯定十分清楚其作用,它的功能就像HTML中的<a href=””>标签一样,只不过是在XAML中实现。

使用Hyperlink 标记的文字在应用中会以特殊颜色显示,当用户点击或触碰该文字时就会自动转到NavigateUri 指向的地址链接。如下代码所示:

<TextBlock FontSize="50" FontWeight="Bold">Getting started tutorials for Windows</TextBlock>
<TextBlock FontSize="25" FontWeight="Bold">New to Windows 8.1 or Windows RT 8.1?</TextBlock>
<RichTextBlock FontSize="30" Width="800" HorizontalAlignment="Left">
    <Paragraph>
        You're at the right place. Whether you're brand new to Windows 8.1 or Windows RT 8.1, 
        or just want a refresher,
        <Hyperlink NavigateUri="http://windows.microsoft.com/en-us/windows/how-to?ocid=GA8-1_O_WOL_Hero_Home_HowTo_Pos2_01">
            these 10 tutorials will show you the basics.</Hyperlink>
    </Paragraph>
</RichTextBlock>

我们把段落中一句文字用NavigateUri 指向特定网站链接,链接颜色默认显示为紫色,可以用Foreground 属性调整颜色。

image

点击Hyperlink 后应用会打开网页,如下图所示:

image

关于Hyperlink 的其他属性可参考:

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.documents.hyperlink.aspx

posted @ 2014-03-08 14:06  Gnie  阅读(1303)  评论(0编辑  收藏  举报
Copyright © 2010 Gnie