TextPointer.IsInSameDocument(TextPointer) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 위치가 현재 위치와 동일한 텍스트 컨테이너에 있는지 여부를 나타냅니다.
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입니다.
반품
예외
textPosition은 null입니다.
예제
다음 예제에서는이 메서드에 대 한 사용을 보여 줍니다. 이 예제에서는 이 메서드를 사용하여 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 작업이 이러한 작업의 현재 위치와 호환되는지 확인합니다.