2016-03-24 9 views
0

私はwpfとvisual basicで作業しています。RichTextBoxの最後の選択のみを選択するためにTextRangeをリセットするにはどうすればよいですか?

dim selection1 as New TextRange(Richtextbox.selection.start,Richtextbox.selection.end) 

以降::私はリッチテキストボックスでテキストを選択すると、私はTextRangeの使用

selection1.ApplyPropertyValue(ForegroundProperty, brushes.Red) 

私は以前の選択で色の変化も、テキストを何度もマーキングしています。私は最後の選択だけを色に変えたい。これを行う方法?

答えて

0

前の選択と前の色をキャッシュしないのはなぜですか?

RichTextBox.BeginChange(); 
selection?.ApplyPropertyValue(ForegroundProperty, lastColor); 
selection = RichTextBox.Selection; 
selection.ApplyPropretyValue(ForegroundProperty, newColor); 
RichTextBox.EndChange(); 
関連する問題