ITextPointer pointer = document.ContentStart; while (pointer.CompareTo(document.ContentEnd) < 0) { pointer = pointer.MoveToNextContextPosition(LogicalDirection.Forward); // Do something with the pointer }
ITextPointer pointer = document.ContentStart; pointer = pointer.GetPositionAtOffset(5); pointer = pointer.MoveToNextContextPosition(LogicalDirection.Forward); // pointer is now at the next context position after the 5th characterIn this example, we first initialize an ITextPointer to the beginning of a document's content and then move the pointer to the 5th character using the GetPositionAtOffset method. We then use the MoveToNextContextPosition method to move the pointer to the next context position after the 5th character. Overall, the MoveToNextContextPosition method is useful for iterating over all context positions in a document or for moving a text pointer to a specific context position in the text. This method is part of the WPF (Windows Presentation Foundation) package library.