This is a migrated thread and some comments may be shown as answers.

IncrementFontSizeCommand, DecrementFontSizeCommand when RadRichTextBox IsReadOnly="true"

1 Answer 10 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Francis
Top achievements
Rank 1
Francis asked on 10 Dec 2013, 07:36 PM
I have a Silverlight app which uses the RadRichTextBox and autowires up the IncrementFontSizeCommand and DecrementFontSizeCommand.  What I was looking to do was have a readonly text box as a viewer, but keeping ability to increase or decrease the font size.  Unfortunately this looks unavailable right out of the box because when the RadRichTextBox.IsReadOnly = true because the command buttons are grey out.

Is there an easy way to achieve this?

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 13 Dec 2013, 03:40 PM
Hello,

The state of the buttons in the ribbon is determined of the state of the command they are bound to. This, on the other hand, depends on the current context in the editor. Simply put, since the document is read-only (cannot be edited), the commands cannot be executed.

What you could do in this regard is remove the command bindings and handle the Click event of the two buttons in the ribbon. Since the methods of RadRichTextBox cannot be used in code-behind when the editor is read-only, you should take advantage of the RadDocumentEditor class and its RespectReadOnlyRanges property as follows:
private void RadRibbonButton_Click_1(object sender, System.Windows.RoutedEventArgs e)
{
    RadDocumentEditor documentEditor = new RadDocumentEditor(this.radRichTextBox.Document);
    documentEditor.RespectReadOnlyRanges = false;
     
    documentEditor.IncrementFontSize();
}

I hope this helps!

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RichTextBox
Asked by
Francis
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or