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

ContextMenu IsEnabled is not working with Commands.

2 Answers 292 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Pushpendra
Top achievements
Rank 1
Pushpendra asked on 17 Dec 2012, 03:00 PM
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 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 20 Dec 2012, 11:42 AM
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.

0
Pushpendra
Top achievements
Rank 1
answered on 20 Dec 2012, 12:27 PM
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
Tags
ScheduleView
Asked by
Pushpendra
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Pushpendra
Top achievements
Rank 1
Share this question
or