ContextMenu IsEnabled is not working with Commands.

3 posts, 0 answers
  1. Pushpendra
    Pushpendra avatar
    32 posts
    Member since:
    Nov 2012

    Posted 17 Dec 2012 Link to this post

    Hi,

    In RadScheduleView I have taken RadContextMenu. I have binded RadMenuItem Command with RadScheduleViewCommands.CreateAppointment and IsEnabled property with a View Model property. Initially I am setting IsEnabled to false in my View Model page, but the menu item is getting enabled first time. This is happning because Command's CanExecute property changes IsEnabled property to true.
    How can I handle this so that RadMenuItem will enable disable based on my View Model Property from initial stage?

    Thanks,
    Pushpendra
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 20 Dec 2012 Link to this post

    Hello Pushpendra,

    The Command of the MenuItem destroys the binding you set to the IsEnabled property and this cannot be changed. What you could do is to use a TwoWay binding instead of OneWay binding - this way it will not be destroyed.

    Another option is to not set directly the command to the MenuItem, but to raise it by hand when the MenuItem is clicked. The easiest way to achieve this is to use a DelegateCommand from your ViewModel and to pass the ScheduleView as parameter. This way you will not need to bind the IsEnabled property of the MenuItem, but manipulate it directly through the CanExecute callback of the command.

    Hope this helps.

    Greetings,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Pushpendra
    Pushpendra avatar
    32 posts
    Member since:
    Nov 2012

    Posted 20 Dec 2012 Link to this post

    Hi Miroslav,

    Thanks for the reply, I have already tried first option that is TwoWay binding of IsEnabled property, but that was not working.
    I will try other solutions suggested by you and let you know.

    Thanks,
    Pushpendra
Back to Top