drag and swap

2 posts, 0 answers
  1. Steven
    Steven avatar
    10 posts
    Member since:
    Apr 2011

    Posted 14 May 2012 Link to this post

    Hi,

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

    Posted 14 May 2012 Link to this post

    Hi Steven,

    As explained in the forum thread at the moment you cannot find the exact location on which the appointment is dropped.  You can get only the Slot and the appointments in it.

    We are sorry for the inconvenience.

    All the best,
    Yana
    the Telerik team

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

  3. DevCraft banner
Back to Top