【发布时间】:2014-05-25 14:49:01
【问题描述】:
我的视图中有一个 RichTextBox 控件。我正在使用代码隐藏(仅 UI 逻辑)来格式化我的 RichTextBox 中的 RTF,它是通过实例化 TextRange 的“格式”按钮单击事件工作的:
private void _btnFormat_Click(object sender, RoutedEventArgs e)
{
TextRange rangeOfText = new TextRange(richTextBoxArticleBody.Document.ContentStart, richTextBoxArticleBody.Document.ContentEnd);
rangeOfText.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black);
rangeOfText.ApplyPropertyValue(TextElement.FontSizeProperty, "12");
rangeOfText.ApplyPropertyValue(TextElement.FontFamilyProperty, "Arial");
rangeOfText.ApplyPropertyValue(TextElement.FontStyleProperty, "Normal");
rangeOfText.ApplyPropertyValue(Inline.TextDecorationsProperty, null);
}
我还想删除 RTF 中的所有表。我可以使用 Table 类中的相同方法从我的 RichTextBox 中删除表格吗?谢谢
【问题讨论】:
标签: c# wpf mvvm richtextbox rtf