简体   繁体   中英

How do I Increase Fontsize for text in richtextbox

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

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

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

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 --

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

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

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

FlowDocument更改它。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM