-
Hi guys,
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
To change a color of a range, for example selection, you can use ApplyPropertyValue: _rtb.Selection.ApplyPropertyValue(TextBlock.ForegroundProperty, Brushes.Red); To get a text of RTB, you need to create a text range first and then you can get or set text: string text = new TextRange(_rtb.Document.ContentStart, _rtb.Document.ContentEnd).Text; E.g. to insert a new line, at the selection start, you create a range and set text in it: TextPointer selectionStart = _rtb.Selection.Start;
new TextRange(selectionStart, selectionStart).Text = Environment.NewLine; to count lines, you either have to count lines in the text retrieved as above (e.g. splitting the string by new line into an array), or you would have to loop through This should get you started. |
Beta Was this translation helpful? Give feedback.
To change a color of a range, for example selection, you can use ApplyPropertyValue:
To get a text of RTB, you need to create a text range first and then you can get or set text:
E.g. to insert a new line, at the selection start, you create a range and set text in it:
to count lines, you either have to count lines in the text retrieved as above (e.g. splitting the string by new line into an array), or y…