| using System.Windows; | |
| namespace WpfRichTextBox | |
| { | |
| public partial class MainWindow : Window | |
| { | |
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| new System.Windows.Documents.TextRange(customRichTextBox.Document.ContentStart, customRichTextBox.Document.ContentEnd).Text = "Hello World!"; | |
| if (customRichTextBox.TextLines.Count > 0 && customRichTextBox.TextLines[0].RichChars.Count > 0) | |
| { | |
| customRichTextBox.TextLines[0].RichChars[0].Color = System.Windows.Media.Colors.Red; | |
| customRichTextBox.TextLines[0].RichChars[0].Position = new System.Windows.Point(50, 50); | |
| customRichTextBox.InvalidateVisual(); | |
| } | |
| } | |
| } | |
| } | |