Clone wiki

Inline HyperlinkButton / Home

WinRT Inline HyperlinkButton

For some very absurd reason, HyperlinkButtons act like blocks rather than inlines and cannot be inserted into InlineCollections such as in a Paragraph directly. If a long HyperlinkButton is put into an InlineUIContainer, the entire container will act as a block and not appear on the same line as preceding and following texts in the paragraph.

Broken wrapping with HyperlinkButton

This is a quick and dirty fix for the problem if you use RichTextBlock in your app. It basically creates a bunch of InlineUIContainers instead of a single one and mimics normal hover and pressed states by linking them together.

Properly wrapping links

Usage

var link = HyperlinkButtonGroup.GetHyperlinkButtonGroup(text, uri);

then

foreach (InlineUIContainer inline in link.Containers)
{
    paragraph.Inlines.Add(inline);
}

You can also optionally specify style and colour

Updated