在Windows 8.1中,microSoft有一个新的控件在Metro:Hyperlink,而不是HyperlinkButton,它是一个内联控件。但它不兼容windows 8。
所以,我想在Windows 8中实现Hyperlink。
但是内联类型没有Tapped Event。
我想问:“如何将Tapped事件添加到Inlin类型控件中;”
答案 0 :(得分:0)
您应该能够HyperlinkButton
TextBlock's
通过Inlines
使用InlineUIContainer
,here。
/// <summary>
/// Appends a HyperlinkButton with
/// the given text and navigate uri to the given RichTextBlock.
/// </summary>
/// <param name="richTextBlock">The rich text block.</param>
/// <param name="text">The text.</param>
/// <param name="uri">The URI.</param>
public static void AppendLink(this RichTextBlock richTextBlock, string text, Uri uri)
{
Paragraph paragraph;
if (richTextBlock.Blocks.Count == 0 ||
(paragraph = richTextBlock.Blocks[richTextBlock.Blocks.Count - 1] as Paragraph) == null)
{
paragraph = new Paragraph();
richTextBlock.Blocks.Add(paragraph);
}
var link =
new HyperlinkButton
{
Content = text,
NavigateUri = uri
};
paragraph.Inlines.Add(new InlineUIContainer { Child = link });
}