TextPointer.GetNextInsertionPosition(LogicalDirection) Methode

Definitie

Retourneert een TextPointer naar de volgende invoegpositie in de opgegeven logische richting.

public:
 System::Windows::Documents::TextPointer ^ GetNextInsertionPosition(System::Windows::Documents::LogicalDirection direction);
public System.Windows.Documents.TextPointer GetNextInsertionPosition(System.Windows.Documents.LogicalDirection direction);
member this.GetNextInsertionPosition : System.Windows.Documents.LogicalDirection -> System.Windows.Documents.TextPointer
Public Function GetNextInsertionPosition (direction As LogicalDirection) As TextPointer

Parameters

direction
LogicalDirection

Een van de LogicalDirection waarden die de logische richting aangeeft waarin wordt gezocht naar de volgende invoegpositie.

Retouren

Een TextPointer die de volgende invoegpositie in de aangevraagde richting aangeeft of null als er geen volgende invoegpositie is gevonden.

Voorbeelden

In het volgende voorbeeld ziet u een gebruik voor deze methode. In het voorbeeld wordt de GetNextInsertionPosition methode gebruikt om de grenzen van inhoudselementen te doorlopen om het aantal elementen te tellen dat Paragraph aanwezig is tussen twee opgegeven TextPointer exemplaren.

// 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.
' This method returns the number of pagragraphs between two
' specified TextPointers.
Private Function GetParagraphCount(ByVal start As TextPointer, ByVal [end] As TextPointer) As Integer
    Dim paragraphCount As Integer = 0

    Do While start IsNot Nothing AndAlso start.CompareTo([end]) < 0
        Dim paragraph As Paragraph = start.Paragraph

        If paragraph IsNot Nothing Then
            paragraphCount += 1

            ' Advance start to the end of the current paragraph.
            start = paragraph.ContentEnd
        End If

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

    Loop ' End while.

    Return paragraphCount

End Function ' End GetParagraphCount.

Opmerkingen

Een invoegpositie is een positie waar nieuwe inhoud kan worden toegevoegd zonder semantische regels voor de bijbehorende inhoud te verbreken. In de praktijk bevindt een invoegpositie zich overal in de inhoud waar een caret kan worden geplaatst. Een voorbeeld van een geldige TextPointer positie die geen invoegpositie is, is de positie tussen twee aangrenzende tags (tussen de afsluitende Paragraph tag van de vorige alinea en de openingstag van de volgende alinea).

Van toepassing op

Zie ook