TextPointer.CompareTo(TextPointer) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 TextPointer 지정된 위치와 지정된 두 번째 TextPointer서수 비교를 수행합니다.
public:
int CompareTo(System::Windows::Documents::TextPointer ^ position);
public int CompareTo(System.Windows.Documents.TextPointer position);
member this.CompareTo : System.Windows.Documents.TextPointer -> int
Public Function CompareTo (position As TextPointer) As Integer
매개 변수
- position
- TextPointer
TextPointer 현재 위치와 비교할 위치를 지정하는 A입니다.
반품
-1이면 현재 TextPointer 앞에 position, 위치가 같으면 0, 현재 TextPointer 위치가 같으면 +1입니다 position.
예외
position 는 현재 위치와 연결된 텍스트 컨테이너 외부의 위치를 지정합니다.
예제
다음 예제에서는이 메서드에 대 한 사용을 보여 줍니다. 이 예제 CompareTo 에서 메서드는 메서드와 함께 GetInsertionPosition 사용되어 지정된 TextElement 메서드가 비어 있는지 여부를 테스트합니다.
// Tests to see if the specified TextElement is empty (has no printatble content).
bool IsElementEmpty(TextElement element)
{
// Find starting and ending insertion positions in the element.
// Inward-facing directions are used to make sure that insertion position
// will be found correctly in case when the element may contain inline
// formatting elements (such as a Span or Run that contains Bold or Italic elements).
TextPointer start = element.ContentStart.GetInsertionPosition(LogicalDirection.Forward);
TextPointer end = element.ContentEnd.GetInsertionPosition(LogicalDirection.Backward);
// The element has no printable content if its first and last insertion positions are equal.
return start.CompareTo(end) == 0;
} // End IsEmptyElement method.
' Tests to see if the specified TextElement is empty (has no printatble content).
Private Function IsElementEmpty(ByVal element As TextElement) As Boolean
' Find starting and ending insertion positions in the element.
' Inward-facing directions are used to make sure that insertion position
' will be found correctly in case when the element may contain inline
' formatting elements (such as a Span or Run that contains Bold or Italic elements).
Dim start As TextPointer = element.ContentStart.GetInsertionPosition(LogicalDirection.Forward)
Dim [end] As TextPointer = element.ContentEnd.GetInsertionPosition(LogicalDirection.Backward)
' The element has no printable content if its first and last insertion positions are equal.
Return start.CompareTo([end]) = 0
End Function ' End IsEmptyElement method.
설명
-1 값은 현재 TextPointer 위치에 지정된 위치가 지정한 위치 position앞에 있음을 나타냅니다. 값이 0이면 표시된 위치가 같음을 나타냅니다. 양수 +1 값은 현재 TextPointer 위치에 지정된 위치가 지정한 위치를 position따른다는 것을 나타냅니다.