Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-specify-whether-a-hyperlink-is-underlined.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.3 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Specify Whether a Hyperlink is Underlined 03/30/2017
csharp
vb
Hyperlink control type [WPF]
3996cfe6-1dac-4835-aeb3-c719ce9cfee5

How to: Specify Whether a Hyperlink is Underlined

The xref:System.Windows.Documents.Hyperlink object is an inline-level flow content element that allows you to host hyperlinks within the flow content. By default, xref:System.Windows.Documents.Hyperlink uses a xref:System.Windows.TextDecoration object to display an underline. xref:System.Windows.TextDecoration objects can be performance intensive to instantiate, particularly if you have many xref:System.Windows.Documents.Hyperlink objects. If you make extensive use of xref:System.Windows.Documents.Hyperlink elements, you may want to consider showing an underline only when triggering an event, such as the xref:System.Windows.ContentElement.MouseEnter event.

In the following example, the underline for the "My MSN" link is dynamic, that is, it only appears when the xref:System.Windows.ContentElement.MouseEnter event is triggered.

Hyperlinks displaying TextDecorations

Example

The following markup sample shows a xref:System.Windows.Documents.Hyperlink defined with and without an underline:

[!code-xamlPerformance#PerformanceSnippet11]

The following code sample shows how to create an underline for the xref:System.Windows.Documents.Hyperlink on the xref:System.Windows.ContentElement.MouseEnter event, and remove it on the xref:System.Windows.ContentElement.MouseLeave event.

[!code-csharpPerformance#PerformanceSnippet15] [!code-vbPerformance#PerformanceSnippet15]

See also