Windows Dev Center

Hyperlink class

Provides an inline-level content element that provides facilities for hosting hyperlinks.




public sealed class Hyperlink : Span


The Hyperlink class has these types of members:


The Hyperlink class has these constructors.

Hyperlink Initializes a new instance of the Hyperlink class.



The Hyperlink class has these events.

Click Occurs when the Hyperlink is clicked.



The Hyperlink class has these methods. It also inherits methods from the Object class.

ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject)
FindName Retrieves an object in the object model / runtime object graph by referencing the object's x:Name or Name attribute value. (Inherited from TextElement)
GetAnimationBaseValue Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject)
GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject)
OnDisconnectVisualChildren Override this method to implement how layout and logic should behave when items are removed from a class-specific content or child property. (Inherited from TextElement)
ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject)
SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject)



The Hyperlink class has these properties.

PropertyAccess typeDescription


Read/writeGets or sets the uniform spacing between characters, in units of 1/1000 of an em. (Inherited from TextElement)


Read-onlyGets a TextPointer that represents the end of the content in the element. (Inherited from TextElement)


Read-onlyGets a TextPointer that represents the start of content in the element. (Inherited from TextElement)


Read-onlyGets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread. (Inherited from DependencyObject)


Read-onlyGets a TextPointer that represents the position just after the end of the element. (Inherited from TextElement)


Read-onlyGets a TextPointer that represents the position just before the start of the element. (Inherited from TextElement)


Read/writeGets or sets the preferred top-level font family for the content of the element. (Inherited from TextElement)


Read/writeGets or sets the font size for the content of the element. (Inherited from TextElement)


Read/writeGets or sets the glyph width of the font in a family to select. (Inherited from TextElement)


Read/writeGets or sets the font style for the content in this element. (Inherited from TextElement)


Read/writeGets or sets the top-level font weight to select from the font family for the content in this element. (Inherited from TextElement)


Read/writeGets or sets the Brush to apply to the content in this element. (Inherited from TextElement)


Read/writeGets an InlineCollection containing the top-level inline elements that include the contents of Span. (Inherited from Span)


Read/writeGets or sets whether automatic text enlargement, to reflect the system text size setting, is enabled. (Inherited from TextElement)


Read/writeGets or sets localization/globalization language information that applies to a TextElement. (Inherited from TextElement)


Read-onlyGets or sets a unique identification for the object. Name can only be set from initial parsing of XAML. (Inherited from TextElement)


Read/writeGets or sets the Uniform Resource Identifier (URI) to navigate to when the Hyperlink is activated.


Read-onlyIdentifies the NavigateUri dependency property.


Read/writeGets or sets a value that indicates what kind of underline is shown under the hyperlink.


Read-onlyIdentifies the UnderlineStyle dependency property.



A Hyperlink element is an Inline derived class. This means it can be placed into an InlineCollection and it's a text element, not a control. It's intended to be part of the text content of a RichTextBlock, but within other text containers. For example a Hyperlink object element in XAML can be one of the elements within the content of a Paragraph. (When the XAML is loaded, the Hyperlink is added to the implicit Inlines/InlineCollection XAML content property of the Paragraph.)

In addition to being part of a Paragraph, a Hyperlink can also be within a Span container, within a TextBlock. For this scenario you may need to apply xml:space="preserve" to other text elements if the Hyperlink is inline between other text elements such as Run.

The property/attribute you set to specify the navigation target of a Hyperlink is NavigateUri. When a user taps a Hyperlink element clicked the value of NavigateUri is passed to a system handler for URI types and schemes. The system then launches the app that is registered for the schema of the URI provided for NavigateUri.

If you don't want the Hyperlink to load content in a default Web browser (and don't want a browser to appear), then don't set a value for NavigateUri. Instead, handle the Click event, and write code that does what you want. For example, you might want an external, absolute URI to load within a WebView control that also exists in your app. For this scenario, you'd call WebView.Navigate as part of your Click handler logic.

Because a Hyperlink is not a UIElement it does not have the set of UI element input events such as Tapped, PointerPressed and so on. Instead, a Hyperlink has its own Click event, plus the implicit behavior of the system loading any URI specified as the NavigateUri. The system handles all input actions that should invoke the Hyperlink actions and fires Click in response.

Hyperlink has restrictions on the content that can exist in its Inlines collection. Specifically, a Hyperlink only permits Run and other Span types that aren't another Hyperlink. InlineUIContainer can't be in the Inlines collection of a Hyperlink. Attempting to add restricted content throws an invalid argument exception or XAML parse exception.

Hyperlink and theme/style behavior

A Hyperlink has a class inheritance that doesn't include FrameworkElement, so it doesn't have a Style property. Nor does a Hyperlink have a Template (it's not a true control). You can edit the properties that are inherited from TextElement such as Foreground or FontFamily to change the appearance of a Hyperlink, but you can't use a common style or template to apply changes. You might consider using common resources for values of Hyperlink properties to provide some consistency to your Hyperlink property values, if you use property values other than the defaults. Some properties of Hyperlink such as Foreground use defaults from a ThemeResource value provided by the system. This enables the Hyperlink appearance to switch in appropriate ways when the user changes the system theme at run-time.

Hyperlink and HyperlinkButton

A Hyperlink and a HyperlinkButton have the similar purpose of enabling a user to launch a specific URI using a separate browser app. The difference between them is that a Hyperlink is a text element that can be placed in formatted text (for example in RichTextBlock) and a HyperlinkButton is a control that can be placed within any layout container that accepts UI elements or controls. A HyperlinkButton might be used within the composition/template of a custom control that enables a web browsing experience.

Requirements (Windows 10 device family)

Device family


API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml::Documents [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml::Documents [C++]





See also




© 2015 Microsoft