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

CancelEditAppointment Not Working

2 Answers 101 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pete
Top achievements
Rank 1
Pete asked on 20 Jan 2012, 12:40 PM
Hi
I'm trying to close the appointment edit dialog using:

RadScheduleViewCommands.CancelEditAppointment.Execute(appointment, ScheduleViewer);

But it does not seem to do anything.

I have added a button to the dialog that needs to execute my code before closing the dialog (so I cannot simple assign Command="telerik:WindowCommands.Cancel" to the button). 

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 24 Jan 2012, 12:53 PM
Hi Pete,

The following code snippet should help:

private void Button_Click(object sender, RoutedEventArgs e)
{  
    var viewModel = (sender as Button).DataContext as AppointmentDialogViewModel;          
    WindowCommands.Cancel.Execute(null, sender as Button);
}

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Pete
Top achievements
Rank 1
answered on 24 Jan 2012, 01:02 PM
Hi thanks.
I can't use this as the button is in the template for the dialog and bound to an ICommand in my ViewModel.
I have got around this now by adding an event handler for the ShowDialog event to the Schedule. When this executes, I store a reference to the dialog in a member variable in the code-behind.
_dialog = e.DialogViewModel as SchedulerDialogViewModel;

When I click the button, I raise an event which is handled in the code-behind and calls
__dialog.Cancel()

Which seems to do the trick!

Thanks


Tags
ScheduleView
Asked by
Pete
Top achievements
Rank 1
Answers by
Yana
Telerik team
Pete
Top achievements
Rank 1
Share this question
or