TextRange(TextPointer, TextPointer) 생성자

정의

지정된 두 TextRange 위치를 새 범위의 시작 위치와 끝 위치로 사용하여 TextPointer 클래스의 새 인스턴스를 초기화합니다.

public:
 TextRange(System::Windows::Documents::TextPointer ^ position1, System::Windows::Documents::TextPointer ^ position2);
public TextRange(System.Windows.Documents.TextPointer position1, System.Windows.Documents.TextPointer position2);
new System.Windows.Documents.TextRange : System.Windows.Documents.TextPointer * System.Windows.Documents.TextPointer -> System.Windows.Documents.TextRange
Public Sub New (position1 As TextPointer, position2 As TextPointer)

매개 변수

position1
TextPointer

TextRange항목을 구성하는 데 사용되는 선택 영역의 한쪽 끝을 표시하는 고정 앵커 위치입니다.

position2
TextPointer

TextRange항목을 구성하는 데 사용되는 선택 영역의 다른 쪽 끝을 표시하는 이동 가능한 위치입니다.

예외

동일한 문서 내에 위치하지 않을 때 position1position2 발생합니다.

을 사용하는 경우 발생 position1position2합니다null.

예제

다음 예제에서는 생성자의 사용을 TextRange 보여 줍니다.

// This method returns a plain text representation of a specified FlowDocument.
string GetTextFromFlowDocument(FlowDocument flowDoc)
{
     // Create a new TextRanage that takes the entire FlowDocument as the current selection.
     TextRange flowDocSelection = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd);
      
     // Use the Text property to extract a string that contains the unformatted text contents 
     // of the FlowDocument.
     return flowDocSelection.Text;
}
' This method returns a plain text representation of a specified FlowDocument.
Private Function GetTextFromFlowDocument(ByVal flowDoc As FlowDocument) As String
    ' Create a new TextRanage that takes the entire FlowDocument as the current selection.
    Dim flowDocSelection As New TextRange(flowDoc.ContentStart, flowDoc.ContentEnd)

    ' Use the Text property to extract a string that contains the unformatted text contents 
    ' of the FlowDocument.
    Return flowDocSelection.Text
End Function

설명

A TextRangeTextPointers가 나타내는 두 위치 사이의 선택 영역에서 형성됩니다. 이러한 위치 중 하나(표시된 position1위치)는 선택 영역과 관련하여 고정되지만 다른 위치(표시된 position2위치)는 이동 가능합니다. 이는 마우스 또는 키보드를 사용하여 사용자가 선택한 항목이 동작하는 방식과 유사합니다.

새 항목이 포함된 문서에 적용할 수 있는 선택 추론과 일치하도록 새 TextRange 문서의 실제 끝을 조정할 수 있습니다 TextRange.

적용 대상