InsertLineBreak and SelectAll Commands Issue

3 posts, 1 answers
  1. Stanescu Mihai
    Stanescu Mihai avatar
    33 posts
    Member since:
    Aug 2009

    Posted 10 May 2011 Link to this post


    I have started to create a simple editor following your demo, but I have a problem with InsertLineBreakCommand and SelectAllCommand. 
    I am using them like this:
    <Button Content="SelectAll" Command="{Binding Path=SelectAllCommand, ElementName=richTextBox}" />
    <Button Content="NewLine" Command="{Binding Path=InsertLineBreakCommand, ElementName=richTextBox}" />

    All other buttons like redo, undo, bold, italic, bullets are done the same way and work. From what I can see is that these specific commands do not return focus to the richtextbox. The weird thing though is that if I hook up an event handler in codebehind for the click event of the buttons and execute the same commands it works great, it even returns focus. 
    Anyone having the same problem?

  2. Answer
    Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 12 May 2011 Link to this post

    Hi Stanescu Mihai,

    The properties of RadRichTextBox which reference commands directly have been obsoleted. 
    We have introduced a Commands property of RadRichTextBox, which encapsulates all available commands. Changing your code to:

    <Button Content="SelectAll" Command="{Binding Path=Commands.SelectAllCommand, ElementName=richTextBox}" />
    <Button Content="NewLine" Command="{Binding Path=Commands.InsertLineBreakCommand, ElementName=richTextBox}" />

    solves the issue.
    You should change the binding Path for all buttons, as in one of the next versions the obsolete properties will be removed altogether and the buttons that are working with the binding from your code-snippet will stop working.
    In the case of RadRichTextBoxRibbonUI the command bindings work this way because, if you notice, the DataContext of RadRichTextBoxRibbonUI is bound to the Commands property of the rich text box. You have the option to do the same, as demonstrated here:

    Another problem that you might face is to update the state of the buttons (UI feedback) to the corresponding state of the text in the RichTextBox (bold, italic). The solution is described in the following thread:

    I hope that helps.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Stanescu Mihai
    Stanescu Mihai avatar
    33 posts
    Member since:
    Aug 2009

    Posted 12 May 2011 Link to this post

    Thanks for the reply Iva,

    Will try that and get back to you later.

    LE: It works. thanks.
Back to Top