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

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

4 Answers 68 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 13 Jan 2012, 12:53 PM
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

4 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 17 Jan 2012, 02:32 PM
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 >>
0
Pete
Top achievements
Rank 1
answered on 20 Jan 2012, 11:10 AM
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


0
Accepted
Konstantina
Telerik team
answered on 23 Jan 2012, 10:38 AM
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 >>
0
Pete
Top achievements
Rank 1
answered on 23 Jan 2012, 11:20 AM
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);
}

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