Hello,
I try to use the RadScheduleViewCommands.DeleteAppointment in a MVVM pattern in my XAML, like this :
<Button Name="DeleteButton" Margin="5"
Content="{x:Static loc:Locals.activity_create_window_delete_btn}"
IsEnabled="{Binding CanDeleteAppointment}"
Command="telerik:RadScheduleViewCommands.DeleteAppointment">
But this doesn't seem to work, as the button is always disabled. I even tried using IsEnabled="True", but it remains the same.
Is this a bug, or is there anything I do wrong ?
Thanks for help.
Boris
I try to use the RadScheduleViewCommands.DeleteAppointment in a MVVM pattern in my XAML, like this :
<Button Name="DeleteButton" Margin="5"
Content="{x:Static loc:Locals.activity_create_window_delete_btn}"
IsEnabled="{Binding CanDeleteAppointment}"
Command="telerik:RadScheduleViewCommands.DeleteAppointment">
But this doesn't seem to work, as the button is always disabled. I even tried using IsEnabled="True", but it remains the same.
Is this a bug, or is there anything I do wrong ?
Thanks for help.
Boris
6 Answers, 1 is accepted
0
Hi Boris,
You would also need to set the CommandTarget property of the Button to point the ScheduleView and the button should work as expected:
Hope this helps.
Regards,
Kalin
Telerik
You would also need to set the CommandTarget property of the Button to point the ScheduleView and the button should work as expected:
<
Button
Command
=
"telerik:RadScheduleViewCommands.DeleteAppointment"
CommandTarget
=
"{Binding ElementName=ScheduleView}"
/>
Hope this helps.
Regards,
Kalin
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0

boris
Top achievements
Rank 1
answered on 13 Jun 2014, 04:44 PM
Hi Kalin, thank you for your quick reply.
As you suggested, I added this line :
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Parent.ScheduleView}"
But that doesn't work neither. Maybe my xaml is more complicated that it looked like. The long story short, the ScheduleView is defined in a template (named EditApppointmentTemplate) used by the EditAppointmentStyle section for customizing the EditAppointment dialog.
This EditAppointmentTemplate is tied to a a view model (EditAppointmentViewModel) that replaces the AppointmentDialogViewModel (this replacement is done in the Grid_loaded event of the Grid contained in the EditApppointmentTemplate).
So, finally, to get a reference to the RadScheduleView, from my EditAppointmentViewModel where lies the code I sent you, I had to get the EditAppointmentTemplate, then get the underlying ScheduleDialog, and then get the ScheduleView property.
In pure C# code, this would such lines of code, if written in my EditAppointmentTemplate.cs :
// Get the Scheduler Dialog
SchedulerDialog dialog = this.MainGrid.TemplatedParent as SchedulerDialog;
// Get the current datacontext
AppointmentDialogViewModel dialogDataContext = (AppointmentDialogViewModel)dialog.DataContext;
// Get a reference to the RadScheduleView
RadScheduleView scheduler = (RadScheduleView)((SchedulerWindow)(dialog.Parent)).ScheduleView;
Well, sorry if it's much work and too complicated, but I'm on this for several days...
Thank you for your help.
As you suggested, I added this line :
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Parent.ScheduleView}"
But that doesn't work neither. Maybe my xaml is more complicated that it looked like. The long story short, the ScheduleView is defined in a template (named EditApppointmentTemplate) used by the EditAppointmentStyle section for customizing the EditAppointment dialog.
This EditAppointmentTemplate is tied to a a view model (EditAppointmentViewModel) that replaces the AppointmentDialogViewModel (this replacement is done in the Grid_loaded event of the Grid contained in the EditApppointmentTemplate).
So, finally, to get a reference to the RadScheduleView, from my EditAppointmentViewModel where lies the code I sent you, I had to get the EditAppointmentTemplate, then get the underlying ScheduleDialog, and then get the ScheduleView property.
In pure C# code, this would such lines of code, if written in my EditAppointmentTemplate.cs :
// Get the Scheduler Dialog
SchedulerDialog dialog = this.MainGrid.TemplatedParent as SchedulerDialog;
// Get the current datacontext
AppointmentDialogViewModel dialogDataContext = (AppointmentDialogViewModel)dialog.DataContext;
// Get a reference to the RadScheduleView
RadScheduleView scheduler = (RadScheduleView)((SchedulerWindow)(dialog.Parent)).ScheduleView;
Well, sorry if it's much work and too complicated, but I'm on this for several days...
Thank you for your help.
0
Hello Boris,
The described scenario is quite complex. However in order to get it working the Button should have a correct CommandTarget and most probably in your case the binding of the CommandTarget of that Button is not correct. What I can suggest you would be to check what you are receiving through that binding using IValueConverter and try to adjust it in order to have the instance of the ScheduleView.
Hope this will help you to achieve the required.
Regards,
Kalin
Telerik
The described scenario is quite complex. However in order to get it working the Button should have a correct CommandTarget and most probably in your case the binding of the CommandTarget of that Button is not correct. What I can suggest you would be to check what you are receiving through that binding using IValueConverter and try to adjust it in order to have the instance of the ScheduleView.
Hope this will help you to achieve the required.
Regards,
Kalin
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0

boris
Top achievements
Rank 1
answered on 19 Jun 2014, 01:58 PM
Hi Kalin,
thank you for your help.
I'll try this soon.
Regards
thank you for your help.
I'll try this soon.
Regards
0

boris
Top achievements
Rank 1
answered on 19 Jun 2014, 03:29 PM
Hi, here I am again.
I tried what you suggested :
public class SchedulerConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (Telerik.Windows.Controls.RadScheduleView)value;
}
}
The converter works fine, the CommandTarget is of type RadScheduleView.
But my problem still remains.
I tried other commands (telerik:WindowCommands.Cancel and telerik:WindowCommands.Confirm). None works. I'm very deceived...
Thank you for your help.
Regards,
Boris
0
Hi Boris,
The reason for the explained behavior is that the button is placed inside of the EditAppointmentDialog. When the dialog is opened the SelectedAppointment is put in edit state and that is why the command is disabled - the appointment cannot be deleted while in edit state.
Hope this helps.
Regards,
Kalin
Telerik
The reason for the explained behavior is that the button is placed inside of the EditAppointmentDialog. When the dialog is opened the SelectedAppointment is put in edit state and that is why the command is disabled - the appointment cannot be deleted while in edit state.
Hope this helps.
Regards,
Kalin
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.