Show AppointmentDialogWindow when an appointment is created (via drag and drop)

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

    Posted 13 Jan 2012 Link to this post

    I am trying to show the AppointmentDialogWindow after a drag-and-drop operation creates an appointment.

    I have added an event handler for ScheduleView.AppointmentCreated.

    If I call :
    RadScheduleViewCommands.EditAppointment.Execute((Appointment)e.CreatedAppointment, ScheduleViewer);

    I get an infinite loop and a StackOverFlowException.
    I tried calling EditAppointment when the AppointmentsSource collection is added to, but at this stage of execute the appointment is still blank.

    (I have read this thread: http://www.telerik.com/community/forums/silverlight/scheduleview/show-appointmentdialogwindow-manually.aspx  but this did not have the answer) 

    Thanks
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 17 Jan 2012 Link to this post

    Hello,

    In order to show the EditAppointmentDialog when dragging and dropping an appointment, you need to execute the command on DragDropCompleted event. You can find more information about the drag-drop behaviour of the RadScheduleView in this help article.

    Hope this helps.

    All the best,
    Konstantina
    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 20 Jan 2012 Link to this post

    I have a DragDropBehavior for my GridView (drag source), which executes DragDropCompleted after I drag and drop onto the ScheduleView. In the override for DragDropCompleted I only have access to the appointment and not the ScheduleView.

    I have a ScheduleViewDragDropBehavior, and the override for Drop(DragDropState) is called, but I cannot get a reference to the ScheduleView on which this behavior is applied. I cannot add a dependency property because the base class DragDropBehavior is not a dependency object.

    There is no DragDropCompleted event on the ScheduleView itself - only a Drop event (which doesn't fire after the item is dropped onto the ScheduleView).

    I cannot see a way to achieve this.

    Thanks


  5. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 23 Jan 2012 Link to this post

    Hello,

    Yes, you are correct, this is a limitation of the DragDropBehaviour. I can suggest you to do the following, but please keep in mind that this is a hack and is better to avoid it if it is not completely necessary:

    var scheduleView = state.ServiceProvider.GetService<IObjectEditor<IAppointment>>() as ScheduleView();

    All the best,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 23 Jan 2012 Link to this post

    Thanks - that's what I needed.

    Unfortunately, the appointment in the DragDropState is not the correct appointment that I need to edit so I have to employ another hack to get it (this is due to the ScheduleView creating several copies of the appointment when using the dialog, which can be seen if a breakpoint is added to the CopyFrom method of the Appointment).

    I've included the code below in case anyone else has the same issue:

    public override void Drop(Telerik.Windows.Controls.DragDropState state)
    {
        base.Drop(state);
        var scheduleView = state.ServiceProvider.GetService<IObjectEditor<IAppointment>>() as RadScheduleView;
        var appointments = scheduleView.AppointmentsSource as ObservableCollection<Appointment>;
        // assume that we are dealing with the last added appointment
        var lastAppointment = appointments.Last();
        RadScheduleViewCommands.EditAppointment.Execute((Appointment)lastAppointment, scheduleView);
    }

Back to Top
DevCraft banner