I'm not sure what I'm attempting is even possible going by this thread:
http://www.telerik.com/community/forums/silverlight/scheduleview/detect-dropping-appointment-on-another.aspx
Basically, I want to be able to drag one appointment onto another one and have specific data on the underlying IAppointment implementation transferred from one appointment to the other and vice-versa.
My issue is being able to get the specific destination appointment when there is more that one appointment filling a particular slot. I want the exact one that the mouse is released upon. Can you please advise if this is possible and if so, how to do it?
FYI., I had tried putting a custom event in my ScheduleViewDragDropBehavior class. The custom event args for this event has a delegate function as a required dependency. The event is fired within the override of the ScheduleViewDragDropBehavior.Drop function. I wanted the code behind of the page that hosts the ScheduleView to invoke my delegate function in the ScheduleViewDragDropBehavior sub-class with the correct destination appointment, but I couldnt get a handle on this whilest dragging the initial appointment. e.g:
public delegate void Test(IEnumerable<UIElement> elements);
public class DelegateFunctionEventArgs : EventArgs
{
public Test DelegateFunction { get; set; }
public DelegateFunctionEventArgs(Test delegateFunction)
{
DelegateFunction = delegateFunction;
}
}
public class NoResizeScheduleViewDragSwapBehavior : ScheduleViewDragDropBehavior
{
public event EventHandler<DelegateFunctionEventArgs> BeginDrop;
public override bool CanResize(DragDropState state)
{
return false;
}
public override bool CanStartResize(DragDropState state)
{
return false;
}
public override void Drop(DragDropState state)
{
if (BeginDrop != null) BeginDrop(this, new DelegateFunctionEventArgs(OnDestinationAppointmentResolved));
base.Drop(state);
}
private void OnDestinationAppointmentResolved(IEnumerable<UIElement> elements)
{
}
}
In the code behind of the page hosting the ScheduleView I handle the BeginDrop as follows:
private void NoResizeScheduleViewDragSwapBehaviorBeginDrop(object sender, DelegateFunctionEventArgs e)
{
var elements = VisualTreeHelper.FindElementsInHostCoordinates(_p, this);
e.DelegateFunction.Invoke(elements);
}
Thanks in advance.