文章出處

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


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()