Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

TextPointer.GetNextInsertionPosition Method

Returns a TextPointer to the next insertion position in the specified logical direction.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
public TextPointer GetNextInsertionPosition(
	LogicalDirection direction
)

Parameters

direction
Type: System.Windows.Documents.LogicalDirection

One of the LogicalDirection values that specifies the logical direction in which to search for the next insertion position.

Return Value

Type: System.Windows.Documents.TextPointer
A TextPointer that identifies the next insertion position in the requested direction, or null if no next insertion position can be found.

An insertion position is a position where new content may be added without breaking any semantic rules for the associated content. In practice, an insertion position is anywhere in content where a caret may be positioned. An example of a valid TextPointer position that is not an insertion position is the position between two adjacent Paragraph tags (that is, between the closing tag of the preceding paragraph and the opening tag of the next paragraph).

The following example demonstrates a use for this method. The example uses the GetNextInsertionPosition method to traverse content element boundaries in order to count the number of Paragraph elements present between two specified TextPointer instances.

// This method returns the number of pagragraphs between two 
// specified TextPointers. 
int GetParagraphCount(TextPointer start, TextPointer end)
{
    int paragraphCount = 0;

    while (start != null && start.CompareTo(end) < 0)
    {
        Paragraph paragraph = start.Paragraph;

        if (paragraph != null)
        {
            paragraphCount++;

            // Advance start to the end of the current paragraph.
            start = paragraph.ContentEnd;
         }

         // Use the GetNextInsertionPosition method to skip over any interceding 
         // content element tags.
         start = start.GetNextInsertionPosition(LogicalDirection.Forward);

     } // End while. 

         return paragraphCount;

}  // End GetParagraphCount.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.