CancelEditAppointment Not Working

3 posts, 0 answers
  1. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 20 Jan 2012 Link to this post

    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. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 24 Jan 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 24 Jan 2012 Link to this post

    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


Back to Top