WpfRichTextBox / MainWindow.xaml.cs
fasdfsa's picture
修改数据结构增加 TextLine
e202030
raw
history blame contribute delete
744 Bytes
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();
}
}
}
}