Skip to main content

HyperlinkButton

The HyperlinkButton is a button that appears as a text hyperlink and opens a URI when you click it. It uses the platform's default mechanism to launch URIs (opening a browser, email client, and so on).

Useful properties

PropertyTypeDescription
NavigateUriUriThe URI to open when the button is clicked.
ContentobjectThe content displayed in the button (typically text).
IsVisitedboolWhether the link has been visited. Automatically set to true after the URI is launched.
CommandICommandAn optional command executed when the button is clicked.

Basic example

<HyperlinkButton NavigateUri="https://avaloniaui.net"
Content="Visit Avalonia" />

Custom content

Like Button, HyperlinkButton supports arbitrary content:

<HyperlinkButton NavigateUri="https://github.com/AvaloniaUI/Avalonia">
<StackPanel Orientation="Horizontal" Spacing="8">
<PathIcon Data="{StaticResource github_icon}" />
<TextBlock Text="View on GitHub" />
</StackPanel>
</HyperlinkButton>

Binding the URI

<HyperlinkButton NavigateUri="{Binding ProjectUrl}"
Content="{Binding ProjectName}" />

Platform behavior

When you click a HyperlinkButton, URI launching is delegated to the operating system's default handler. The browser or application that opens depends on your platform settings. For example, a https:// link opens in your default web browser, while a mailto: link opens in your default email client.

Pseudoclasses

PseudoclassDescription
:visitedApplied when IsVisited is true.
:pressedApplied while the button is being pressed.

See also