mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-05 23:42:58 +02:00
* 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
34 lines
2.3 KiB
Markdown
34 lines
2.3 KiB
Markdown
---
|
|
title: "How to: Specify Whether a Hyperlink is Underlined"
|
|
ms.date: "03/30/2017"
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "Hyperlink control type [WPF]"
|
|
ms.assetid: 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.
|
|
|
|

|
|
|
|
## Example
|
|
The following markup sample shows a <xref:System.Windows.Documents.Hyperlink> defined with and without an underline:
|
|
|
|
[!code-xaml[Performance#PerformanceSnippet11](~/samples/snippets/csharp/VS_Snippets_Wpf/Performance/CSharp/Hyperlink.xaml#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-csharp[Performance#PerformanceSnippet15](~/samples/snippets/csharp/VS_Snippets_Wpf/Performance/CSharp/Hyperlink.xaml.cs#performancesnippet15)]
|
|
[!code-vb[Performance#PerformanceSnippet15](~/samples/snippets/visualbasic/VS_Snippets_Wpf/Performance/visualbasic/hyperlink.xaml.vb#performancesnippet15)]
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.TextDecoration>
|
|
- <xref:System.Windows.Documents.Hyperlink>
|
|
- [Optimizing WPF Application Performance](optimizing-wpf-application-performance.md)
|
|
- [Create a Text Decoration](how-to-create-a-text-decoration.md)
|