'WinUI HyperlinkButton is not displayed underlined
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
Solution 1:[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>
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
