Disable MenuItems on Dynamic Menu

5 posts, 0 answers
  1. gans
    gans avatar
    48 posts
    Member since:
    Jan 2012

    Posted 28 Aug 2012 Link to this post

    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. 
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 29 Aug 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Pana
    Admin
    Pana avatar
    748 posts

    Posted 29 Aug 2012 Link to this post

    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.

  5. gans
    gans avatar
    48 posts
    Member since:
    Jan 2012

    Posted 29 Aug 2012 Link to this post

    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. 

  6. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 30 Aug 2012 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready