Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Hyperlink Class
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Hyperlink Class

An inline-level flow content element that provides facilities for hosting hyperlinks within flow content.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/xaml/presentation
Visual Basic (Declaration)
<UIPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted := True)> _
Public Class Hyperlink _
    Inherits Span _
    Implements ICommandSource, IUriContext
Visual Basic (Usage)
Dim instance As Hyperlink
C#
[UIPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted = true)]
public class Hyperlink : Span, ICommandSource, 
    IUriContext
Visual C++
[UIPermissionAttribute(SecurityAction::InheritanceDemand, Unrestricted = true)]
public ref class Hyperlink : public Span, 
    ICommandSource, IUriContext
JScript
public class Hyperlink extends Span implements ICommandSource, IUriContext
XAML Object Element Usage
<Hyperlink>
  Inlines
</Hyperlink>

Hyperlink implements the NavigateUri property that you set with the Uri of the content that should be navigated to when the Hyperlink is clicked. Hyperlink navigation can only occur, however, if either the direct or indirect parent of a Hyperlink is a navigation host, including NavigationWindow, Frame, or any browser that can host XBAPs (which includes Internet Explorer 7, Microsoft Internet Explorer 6, and Firefox 2.0+). For more information, see the Navigation Hosts topic in Navigation Overview.

Content Model: Hyperlink enforces a strong content model for child content. See TextElement Content Model Overview for more information about the Hyperlink content model.

The following example shows simple use of a Hyperlink element.

C#
<Paragraph>
  <Run>Text preceding the hyperlink.</Run>
  <Hyperlink
    NavigateUri="http://search.msn.com"
  >
    Link text.
  </Hyperlink>
  <Run Name="test">Text following the hyperlink.</Run>
</Paragraph>

The following example shows how to create a Hyperlink programmatically.

C#
Paragraph parx = new Paragraph();
Run run1 = new Run("Text preceeding the hyperlink.");
Run run2 = new Run("Text following the hyperlink.");
Run run3 = new Run("Link Text.");

Hyperlink hyperl = new Hyperlink(run3);
hyperl.NavigateUri = new Uri("http://search.msn.com");

parx.Inlines.Add(run1);
parx.Inlines.Add(hyperl);
parx.Inlines.Add(run2);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker