I have several controls on my form, among which some RichTextBox instances. The for has RadRichTextBoxRibbonUI on top. When a RichTextBox gets the focus (GotFocus event) I'm binding the DataContext of the ribbon with its Commands property. When focus is lost (LostFocus) I want to disable this binding and disable all the buttons of the ribbon that are bound to the richtextbox commands (all the buttons of the ribbon that have the RadRichTextBoxRibbonUI.RichTextCommand attribute).
How can I do that? Setting the DataContext of the ribbon to null does not disable it.
5 Answers, 1 is accepted
By default the button controls are enabled even when they don't have a binding. That's why removing the data context command property does not affect their state to disabled. Our suggestion is to traverse through all the buttons in the ribbon and manually set their state.
If you find difficulties in implementing such behavior, write back to us.
Martin
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.
You can use the IsEnabled property of the ribbon elements to disable them. In order to determine which buttons should be enabled and disabled, you can give them names in XAML.
You can also use the ChildrenOfType<T> extension method from the Telerik.Windows.Controls assembly.
First you need to add:
using
Telerik.Windows.Controls;
Then you can use it to disable all controls of a certain type like this:
foreach
(var item
in
this
.radRichTextBoxRibbonUI1.ChildrenOfType<RadRibbonComboBox>())
{
item.IsEnabled =
false
;
}
I hope this helps.
Martin
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Any ideas?
Maybe better solution would be to enable/disable all needed groups in the ribbon - for example by binding their IsEnabled property to your custom converter, which computes when RadRichTextBox has focus.
Another option is to give names to all the groups, and in case of losing/receiving focus manually set the IsEnabled properties of the groups.
You can also set IsEnabled property of the tabs itself, but this would make them unselectable.
Regards,
Boby
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.