Italic Constructor (TextPointer, TextPointer)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Initializes a new instance of the Italic class with the specified TextPointer objects that indicate the beginning and end of a content selection that the new Italic will contain.

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

public Italic(
	TextPointer start,
	TextPointer end


Type: System.Windows.Documents.TextPointer

The beginning of a selection of content that the new Italic will contain.

Type: System.Windows.Documents.TextPointer

The end of a selection of content that the new Italic will contain.

Exception Condition

start or end is null.


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

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 italic.");
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 Italic.  In this case, the new Italic
// will enclose the second text run, "run2".
Italic italx = new Italic(run2.ContentStart, run2.ContentEnd);

.NET Framework
Available since 3.0
Return to top