Hyperlink Constructor (TextPointer, TextPointer)

Initializes a new instance of the Hyperlink class, taking two TextPointer objects that indicate the beginning and end of a selection of content to be contained by the new Hyperlink.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

public function Hyperlink(
	start : TextPointer, 
	end : TextPointer
)
You cannot use constructors in XAML.

Parameters

start
Type: System.Windows.Documents.TextPointer

A TextPointer indicating the beginning of a selection of content to be contained by the new Hyperlink.

end
Type: System.Windows.Documents.TextPointer

A TextPointer indicating the end of a selection of content to be contained by the new Hyperlink.

ExceptionCondition
ArgumentNullException

start or end is a null reference (Nothing in Visual Basic).

ArgumentException

start and end do not resolve to a range of content suitable for enclosure by a Span element; for example, if start and end indicate positions in different paragraphs.

This constructor is intended to initialize a new Hyperlink element such that it encloses a selection of preexisting content.

The following example demonstrates usage of this constructor.

// Create a paragraph and three text runs to serve as example content.  
Paragraph parx = new Paragraph();
Run run1 = new Run("Text run 1.");
Run run2 = new Run("Text to link.");
Run run3 = new Run("Text run 3.");

// Add the three text runs to the paragraph, separated by linebreaks.
parx.Inlines.Add(run1);
parx.Inlines.Add(new LineBreak());
parx.Inlines.Add(run2);
parx.Inlines.Add(new LineBreak());
parx.Inlines.Add(run3);

// After this line executes, the selection of content 
// indicated by the "start" and "end" parameters will be
// enclosed by the new Hyperlink.  In this case, the new Hyperlink 
// will enclose the entire contents of the the text run "run2".  
Hyperlink hyperl = new Hyperlink(run2.ContentStart, run2.ContentEnd);

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft