TextPointer.IsInSameDocument(TextPointer) 메서드

정의

지정된 위치가 현재 위치와 동일한 텍스트 컨테이너에 있는지 여부를 나타냅니다.

public:
 bool IsInSameDocument(System::Windows::Documents::TextPointer ^ textPosition);
public bool IsInSameDocument(System.Windows.Documents.TextPointer textPosition);
member this.IsInSameDocument : System.Windows.Documents.TextPointer -> bool
Public Function IsInSameDocument (textPosition As TextPointer) As Boolean

매개 변수

textPosition
TextPointer

TextPointer 현재 위치와 비교할 위치를 지정하는 A입니다.

반품

현재 위치와 동일한 텍스트 컨테이너에 있는 위치를 나타내면 />이고, 그렇지 않으면 .

예외

textPositionnull입니다.

예제

다음 예제에서는이 메서드에 대 한 사용을 보여 줍니다. 이 예제에서는 이 메서드를 사용하여 IsInSameDocument 세 위치가 모두 동일한 텍스트 컨테이너에 속한다는 보장이 없는 상황에서 지정된 인스턴스가 다른 두 개의 지정된 TextPointer 인스턴스 사이에 배치되는지 여부를 TextPointer 확인합니다.

// This method first checks for compatible text container scope, and then checks whether
// a specified position is between two other specified positions.
bool IsPositionContainedBetween(TextPointer positionToTest, TextPointer start, TextPointer end)
{
    // Note that without this check, an exception will be raised by CompareTo if positionToTest 
    // does not point to a position that is in the same text container used by start and end.
    //
    // This test also implicitely indicates whether start and end share a common text container.
    if (!positionToTest.IsInSameDocument(start) || !positionToTest.IsInSameDocument(end)) 
        return false;
    
    return start.CompareTo(positionToTest) <= 0 && positionToTest.CompareTo(end) <= 0;
}
' This method first checks for compatible text container scope, and then checks whether
' a specified position is between two other specified positions.
Private Function IsPositionContainedBetween(ByVal positionToTest As TextPointer, ByVal start As TextPointer, ByVal [end] As TextPointer) As Boolean
    ' Note that without this check, an exception will be raised by CompareTo if positionToTest 
    ' does not point to a position that is in the same text container used by start and end.
    '
    ' This test also implicitely indicates whether start and end share a common text container.
    If (Not positionToTest.IsInSameDocument(start)) OrElse (Not positionToTest.IsInSameDocument([end])) Then
        Return False
    End If

    Return start.CompareTo(positionToTest) <= 0 AndAlso positionToTest.CompareTo([end]) <= 0
End Function

설명

여러 TextPointer 인스턴스를 포함하는 대부분의 작업은 해당 인스턴스가 동일한 텍스트 컨테이너 범위에 있는 위치를 나타내는 경우에만 유효합니다. 예를 들어 현재 CompareTo 위치와 GetOffsetToPosition 연결된 텍스트 컨테이너 외부의 위치와 메서드 TextPointer 를 사용할 수 없습니다. 이 메서드를 사용하여 지정된 TextPointer 작업이 이러한 작업의 현재 위치와 호환되는지 확인합니다.

적용 대상