0

I am using the WinUI technology.

I would like to display a HyperlinkButton in my XAML.

The problem is that the HyperlinkButton is not displayed underlined. But according to this documentation this should be the case / the default behavior: MSDN - HyperlinkButton Class

Here is what I have:

<HyperlinkButton Content="Example" Click="HyperlinkButton_Click" />

Neither I have any style that would affect how the button is displayed nor did I change a template.

What am I missing? Thank you.


UPDATE

The problem exists in version 1.0.1 (march 2022) of Windows App SDK as well as in version 1.0.0 (november 2021), see windows-app-sdk/downloads

1
  • 1
    I got the result same as you. And I'm trying to consult. Commented Apr 1, 2022 at 1:42

2 Answers 2

1

The template of the HyperlinkButton has changed in later versions of the Windows App SDK (1.0.0+) but apparently the documentation hasn't been updated.

You should still be able to use a Hyperlink element to get an underlined link though:

<TextBlock>
    <Hyperlink Click="Hyperlink_Click">Example</Hyperlink>
</TextBlock>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer. I have a visual studio project that still targets Windows App SDK version 1.0.0 and the behavior is the same, i.e. the link is not displayed underlined. So I presume that new version 1.0.1 has nothing to do with this? However the example you provided with the Hyperlink inside a TextBlock works, the link is displayed underlined. Should we remove the part of the answer that mentions the new version of the Windows App SDK? I will update my question respectivly (the problem exists in 1.0.0 and 1.0.1).
I guess it was modified prior to 1.0.1 being released then. I edited the answer slightly. Anyway, the templates has changed and the text of a HyperlinkButton is no longer underlined by default.
1

HyperlinkButton missing underlined text is almost confirmed a bug.
As a workaround to add underline on the button text string, you can try the following way to display something with TextDecorations property as "Underline".

        <HyperlinkButton Click="HyperlinkButton_Click">
            <TextBlock Text="www.microsoft.com" TextDecorations="Underline" />
        </HyperlinkButton>

Edit:
Finally, according to the issue,

The documentation needs updating to reflect the updated design for HyperlinkButton first introduced in WinUI 2.6, see the WinUI Figma toolkit for more info.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.