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

Disable MenuItems on Dynamic Menu

4 Answers 205 Views
Menu
This is a migrated thread and some comments may be shown as answers.
gans
Top achievements
Rank 1
gans asked on 28 Aug 2012, 03:15 PM
I have a requirement where my Menu Items has to be Disabled/Enabled dynamically based on user Actions. Please let me know if you have an example that does this. My Menu Items are not static and they are Data Driven. 

4 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 29 Aug 2012, 10:01 AM
Hello,

Each RadMenuItem has IsEnabled property. You may bind it and set the value based on the users actions. More information for Binding to Dynamic Data can be found in our online help here. You can install our WPF demos from here and check the "Data Binding" example for RadMenu in which such binding is implemented (items there are static, but I think you may find it useful).

Also you can bind the Command property of the RadMenuItems to an implementation of ICommand. Then when the ICommand notify for CanExecuteChanged the RadMenuItems will update their state based on the result of the ICommand's CanExecute method. If it returns false the RadMenuItems will appear disabled.

Please check these two sources and if you still have something unclear please send us some details for this case and how would you want to disable/enable the RadMenuItems. A sample project will be a great help for us.

Looking forward to hearing from you!

Greetings,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Pana
Telerik team
answered on 29 Aug 2012, 10:03 AM
Hello,

Each RadMenuItem has IsEnabled property. You may bind it and set the value based on the users actions. More information for Binding to Dynamic Data can be found in our online help here. You can install our WPF demos from here and check the "Data Binding" example for RadMenu in which such binding is implemented (items there are static, but I think you may find it useful).

Also you can bind the Command property of the RadMenuItems to an implementation of ICommand. Then when the ICommand notify for CanExecuteChanged the RadMenuItems will update their state based on the result of the ICommand's CanExecute method. If it returns false the RadMenuItems will appear disabled.

Please check these two sources and if you still have something unclear please send us some details for this case and how would you want to disable/enable the RadMenuItems. A sample project will be a great help for us.

Looking forward to hearing from you!

Greetings,
Pana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
gans
Top achievements
Rank 1
answered on 30 Aug 2012, 03:25 AM
Thanks for your suggestions. I am able to generate Menu Items Dynamically. I am only having issues Disabling using Commands. 

I like the idea of using ICommand and CanExecute methods. But not sure how to have these attached just for the MenuItems and not for the Window. 

I have create a support ticket  585684  and attached Sample project that does this. 

Any help on this is very much appreciated. 

0
Rosen Vladimirov
Telerik team
answered on 30 Aug 2012, 03:00 PM
Hello,

Thanks for the project you have sent. We have implemented a new solution for you - when you right click on the buttons you can choose one of the items and this leads to disabling the items from the same group in the other two buttons context menus. We've also added a "Clear" item to clear the value of the button (without it you'll always come to a deadlock at the end - you'll have no options to change your selection).

Also if you want to disable the group menu item and not the inner menu items you can add a boolean property IsAvailable on the MenuGroup, implement property changed notification and set it to true or false based on the selection. On the other hand you should bind the menu items' IsEnabled to the IsAvailable property.

Hopefully this is the case you are working on and it resolves your problem.
Please check the attached solution and inform us if you still have problems with your implementation.

Regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Menu
Asked by
gans
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Pana
Telerik team
gans
Top achievements
Rank 1
Share this question
or