Jeff B
Jeff B

Reputation: 1866

Change font increment for WPF RichTextBox

I'm using a WPF RichTextBox control to input some text with user formatting capability, including font size adjustment. The built-in commands for IncreaseFontSize and DecreaseFontSize will adjust the font size by 0.75pt each time the command is executed. I would like to increase the granularity to 2pt.

Can this be done without implementing my own custom commands?

Upvotes: 1

Views: 1532

Answers (2)

Scott
Scott

Reputation:

That doesn't work for InlineContainers that are text blocks

Upvotes: 0

ligaz
ligaz

Reputation: 2121

Unfortunately the value is hard-coded and you cannot change it. The fastest way to implement this is to use the TextRange class. Something like this:

var range = new TextRange( rtb.Document.ContentStart, rtb.Document.ContentEnd );
range.ApplyPropertyValue( TextElement.FontSizeProperty, 30.0 );

Upvotes: 1

Related Questions