wpf 如何增加富文本框中文本的字体大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34872058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 13:38:00  来源:igfitidea点击:

How do I Increase Fontsize for text in richtextbox

c#wpfrichtextboxfont-size

提问by arjun sanju

How to set font size in each time i call a method.i want to use richtextbox.ApplyPropertyValue()method. I already tried

每次调用richtextbox.ApplyPropertyValue()方法时如何设置字体大小。我想使用方法。我已经试过了

myrichtextbox.SetValue(TextElement.FontSizeProperty, fontSizedouble +10);

myrichtextbox.FontSize = (myrichtextbox.FontSize + 10);

回答by Muds

For rich text box you need selection--

对于富文本框,您需要选择--

try this

尝试这个

TextSelection selectedText = myrichtextbox.Selection;

selectedText.ApplyPropertyValue(RichTextBox.FontSizeProperty, fontSizedouble +10);

For all text you can try this --

对于所有文本,你可以试试这个——

TextRange allText = new TextRange(MyRichTextBox.Document.ContentStart, MyRichTextBox.Document.ContentEnd);

allText.ApplyPropertyValue(RichTextBox.FontSizeProperty, fontSizedouble +10);

And to change size again and again you need to check size for text not richTextBox, do this --

并且要一次又一次地更改大小,您需要检查文本的大小而不是richTextBox,请执行此操作-

TextRange allTextRange = new TextRange(MyRichTextBox.Document.ContentStart, MyRichTextBox.Document.ContentEnd);

var size = (double)allTextRange.GetPropertyValue(FontSizeProperty);

allTextRange.ApplyPropertyValue(RichTextBox.FontSizeProperty, size + 10);

回答by Prince Owen

Change it from your FlowDocument.

从您的FlowDocument.

this.Document.FontSize = this.Document.FontSize + 10;