简体   繁体   English

如何在Windows8中实现超链接控制

[英]How to Implement Hyperlink Control in windows8

In Windows 8.1 microSoft has a new control In metro:Hyperlink,which is to Instead of HyperlinkButton, it is a inline control。 but it did not Compatible with windows 8. 在Windows 8.1中,microSoft在Metro:Hyperlink中有一个新控件,它是一个内联控件,而不是HyperlinkBut​​ton,它是一个内联控件。但它与Windows 8不兼容。

so, I want to Implement Hyperlink in windows 8. 因此,我想在Windows 8中实现超链接。

but Inline type didn't have Tapped Event. 但是内联类型没有点击事件。

I want to ask: "how to add Tapped event into a Inlin type control;" 我想问:“如何将Tapped事件添加到Inlin类型控件中;”

You should be able to use HyperlinkButton inside of a TextBlock's Inlines through a InlineUIContainer as in here . 您应该能够通过InlineUIContainerTextBlock's Inlines使用HyperlinkButton ,如此处所示

    /// <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 });
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM