如何检测WPF RichTextBox中光标位置的当前文本格式?
该主题的作者还询问了TextDecorations,其中没有提供示例代码及其使用的不同.我发布这个作为进一步的解决方案:
var obj = _myText.GetPropertyValue(Inline.TextDecorationsProperty);
if (obj == DependencyProperty.UnsetValue)
IsTextUnderline = false;// mixed formatting
if (obj is TextDecorationCollection)
{
var objProper = obj as TextDecorationCollection;
if (objProper.Count > 0)
IsTextUnderline = true; // all underlined
else
IsTextUnderline = false; // nothing underlined
}
Run Code Online (Sandbox Code Playgroud)