This is a migrated thread and some comments may be shown as answers.
Disabling RadRichTextBoxRibbonUI when focus is not on a RichTextBox
5 Answers 29 Views
This is a migrated thread and some comments may be shown as answers.
papadi
Top achievements
Rank 1
papadi asked on 27 Sep 2012, 02:03 PM
Hi!
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

Sort by
0
Martin Ivanov
Telerik team
answered on 01 Oct 2012, 09:30 AM
Hello papadi,

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.

Greetings,
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.

0
papadi
Top achievements
Rank 1
answered on 01 Oct 2012, 02:02 PM
Can you help me with that? Should I use the Items property of the ribbon or there is an easier way to get the collection of buttons in the ribbon?
0
Martin Ivanov
Telerik team
answered on 04 Oct 2012, 11:44 AM
Hello Dimitrios,

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.

All the best,
Martin
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
papadi
Top achievements
Rank 1
answered on 27 May 2013, 02:53 PM
I'm coming back after quite a while with this. Back then I did use the ChildrenOfType method to get the items of the ribbon. The problem now is that I discovered that this function returns only the items of the currently visible tab and not all of the items of the Ribbon!
Any ideas?
0
Boby
Telerik team
answered on 30 May 2013, 11:43 AM
Hi Papadi,
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.

Asked by
papadi
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
papadi
Top achievements
Rank 1
Boby
Telerik team
Share this question
or