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

InsertLineBreak and SelectAll Commands Issue

2 Answers 63 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stanescu Mihai
Top achievements
Rank 1
Stanescu Mihai asked on 10 May 2011, 03:18 PM
Hello,

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 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 12 May 2011, 04:30 PM
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:

http://www.telerik.com/help/silverlight/radrichtextbox-features-commands.html

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:
http://www.telerik.com/community/forums/silverlight/richtextbox/radribbontogglebuttons-and-radribbonbuttons-in-a-radtoolbar.aspx

I hope that helps.


Regards,
Iva
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
0
Stanescu Mihai
Top achievements
Rank 1
answered on 12 May 2011, 04:32 PM
Thanks for the reply Iva,

Will try that and get back to you later.

LE: It works. thanks.
Tags
RichTextBox
Asked by
Stanescu Mihai
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Stanescu Mihai
Top achievements
Rank 1
Share this question
or