如何检测 WPF RichTextBox 中光标位置的当前文本格式?

最佳答案

试试下面的代码,其中 rtb 是 RichTextBox:

TextRange tr = new TextRange(rtb.Selection.Start, rtb.Selection.End);
object oFont = tr.GetPropertyValue(Run.FontFamilyProperty);

10-06 14:43