IncrementFontSizeCommand, DecrementFontSizeCommand when RadRichTextBox IsReadOnly="true"

2 posts, 0 answers
  1. Francis
    Francis avatar
    2 posts
    Member since:
    Jan 2012

    Posted 10 Dec 2013 Link to this post

    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?
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 13 Dec 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top