TextRange(TextPointer, TextPointer) コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した 2 つの 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の形成に使用される選択範囲のもう一方の端をマークする移動可能な位置。
例外
position1とposition2が同じドキュメント内に配置されていない場合に発生します。
position1またはposition2が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
注釈
TextRangeは、TextPointers によって示される 2 つの位置の選択から形成されます。 これらの位置の一方( position1で示される)は選択に対して固定され、もう一方の位置( position2で示される)は移動可能である。 これは、マウスまたはキーボードを使用してユーザーが選択した動作に似ています。
新しい TextRange の実際の終了は、新しい TextRangeを含むドキュメントに適用できる任意の選択ヒューリスティックと一致するように調整できます。