winform中的richtextbox比较熟悉
选择文本 richtextboxselection start richtextboxselection end
然后就是设置字体,richtextbox.selectionfont selectionbackcolor之类的
那么在wpf当中怎么设置richtextbox的字体呢
TextRange textRange = new TextRange(
// TextPointer to the start of content in the RichTextBox.
richtext_claim.Document.ContentStart,
// TextPointer to the end of content in the RichTextBox.
richtext_claim.Document.ContentEnd
);
//textRange.ApplyPropertyValue(TextElement.BackgroundProperty, "yellow");
textRange.ApplyPropertyValue(TextElement.BackgroundProperty, "yellow");
textRange.ApplyPropertyValue(Run.TextDecorationsProperty, TextDecorations.Underline);
其中具体的属性可以参考如下具体的代码
//Set Bold formatting to selected content
private void BtnBold_Click(object sender, RoutedEventArgs e)
{
if