Export (0) Print
Expand All

Underline.Underline(TextPointer, TextPointer) Constructor

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

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

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



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


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

Exception typeCondition


Raised when start or end is null.


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

This constructor is intended to initialize a new Underline element such that it encloses a selection of pre-existing 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 run 2, make underlined.");
Run run3 = new Run("Text run 3.");

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

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2014 Microsoft