ListBox drag-drop behavior

30 posts, 0 answers
  1. Valeri Hristov
    Valeri Hristov avatar
    40 posts
    Member since:
    Dec 2003

    Posted 04 Aug 2011 Link to this post

    With RadScheduleView we began pushing a new model for drag-drop implementations, the so called DragDropBehavior, which is trying to hide the underlying UI elements, events, etc. and let you only work with the dragged data. We believe that this new layer of abstraction greatly simplifies the drag-drop implementations as you don’t need to understand the control structure and drag-drop events. In addition, as you are working only with data, you could create very complex business logic inside this behavior that can be easily tested.

    Since the ScheduleView <–> ListBox is one of the most common drag-drop scenarios, we created a simple attached behavior that does everything for you – copy, move, reorder items in a ListBox. In case you are dragging from other control, such as RadScheduleView, or from a different application, it will automatically insert the dragged items in the ListBox.

    I would be glad to get your feedback!

    UPDATE Q3 2011 (version 2011.3.1116)
    The behaviors are almost official, we already have online help:
    http://www.telerik.com/help/silverlight/dragdropmanager-behaviors-listboxandscheduleview.html

    And an example:
    http://demos.telerik.com/silverlight/#ScheduleView/DragDrop

    And also attached is a simple application that demonstrates how to implement behaviors for RadTreeView and RadGridView.

    Regards,
    Valeri Hristov
    Telerik

  2. Vadim
    Vadim avatar
    6 posts
    Member since:
    Apr 2011

    Posted 09 Aug 2011 Link to this post

    It doesn't work with latest internal build 808... :(
  3. DevCraft banner
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Aug 2011 Link to this post

    Hello Vadim,

    You are correct, the attached binaries are compiled against version 2011.2.801, hence they cannot work with other internal builds. I will upload new binaries once this week's internal build is online.

    All the best,
    Valeri Hristov
    the Telerik team

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

  5. Vadim
    Vadim avatar
    6 posts
    Member since:
    Apr 2011

    Posted 18 Aug 2011 Link to this post

    Are you talking about 815 build that is already available? Or upcoming monday 822 build?
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 22 Aug 2011 Link to this post

    Hello Vadim,

    The drag-drop behaviors will be included in the Telerik.Windows.Controls.dll in the today's internal build, e.g. you will not have to reference Telerik.Windows.DragDrop.Extensions.dll if you are using internal build with version 2011.2.822 and newer.

    Regards,
    Valeri Hristov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  7. Jorn
    Jorn avatar
    222 posts
    Member since:
    Jun 2009

    Posted 23 Aug 2011 Link to this post

    Where is the build? Now it must be called 2011.2.823.
  8. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 24 Aug 2011 Link to this post

    The build was delayed a little bit, its version is 2011.2.823.

    Regards,
    Valeri Hristov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  9. Vadim
    Vadim avatar
    6 posts
    Member since:
    Apr 2011

    Posted 25 Aug 2011 Link to this post

    Thank you,
    It is working perfectly!
  10. Vadim
    Vadim avatar
    6 posts
    Member since:
    Apr 2011

    Posted 29 Aug 2011 Link to this post

    Valeri,

    Using new drag-drop manager in example that you have attached, how can i create DragCue in a way that it would be right under mouse cursor?

    When i'm creating drag cue using CreateVisualCue, it always appears at the top/left corner of the dragged item, instead of cursor location;

    public override FrameworkElement CreateVisualCue(ListBoxDragDropState state)
            {         
                ContentControl element = new ContentControl();          
                element.Content = state.DraggedItems.FirstOrDefault();
                return element;         
            }
  11. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 29 Aug 2011 Link to this post

    Hello Vadim,

    Currently the ListBoxDragDropBehavior does not support setting an offset between the top-left corner of the drag visual and the mouse pointer, and there is no workaround. Unfortunately it is too late for something to enter in the today's internal build, so the best we can do is to include the feature in the next week's internal build.

    All the best,
    Valeri Hristov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  12. Ronald
    Ronald avatar
    11 posts
    Member since:
    Sep 2011

    Posted 09 Sep 2011 Link to this post

    Hi Valeri,

    Thank you very much for this interesting example.
     
    One thing I noticed while using your code:
    When I drag an item from a listbox to the scheduleview, the item is not deleted from the listbox.
    This is only the case when I hold the SHIFT-key during dragging.

    Any idea how I can delete the items from the listbox by default after dropping them on the scheduleview?

    Everything works fine in the other way: when I drag an item from the scheduleview to the listbox, it is correctly deleted from the scheduleview.

    Thank you very much in advance.

    Kind regards,
    Ronald
  13. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 12 Sep 2011 Link to this post

    Hi Ronald,

    You need to subclass the ListBoxDragDropBehavior and override the IsMovingItems method like this:
    protected virtual bool IsMovingItems(ListBoxDragDropState state)
    {
        return !state.IsSameControl || base.IsMovingItems(state);
    }

    Kind regards,
    Valeri Hristov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  14. Ronald
    Ronald avatar
    11 posts
    Member since:
    Sep 2011

    Posted 12 Sep 2011 Link to this post

    Hi Valeri,

    Thank you very much, it is working now.
    Have a nice day !

    Kind regards,
    Ronald
  15. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    Valeri,

    as i posted in this thread, the guidelines seem to be unusable due to the protection level of some methods. Moreover, the documentation is not really usable in this form; there are plenty of conflicting informations between using a custom ScheduleViewDragDropBehavior, a custom DragDrop, etc...

    Could you clarify how one is supposed to design drag and drop from a control to a scheduleview, with conversion (or not)? What classes must be used, etc...
  16. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 29 Sep 2011 Link to this post

    Hello Samy,

    The drag-drop behaviors are still experimental, hence they are not completely open. Currently, except the built-in ScheduleView behavior, you could only use the ListBoxDragDrop behavior. We are working on similar behavior for RadGridView and RadTreeView, that will appear in the upcoming internal builds. We are aiming to provide official state for the behaviors (extensible API, support for more Telerik controls, better documentation etc.) for Q3 2011 in mid November.

    Best wishes,
    Valeri Hristov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  17. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    So what is the current official way to build applications against drag and drop capabilities between these controls? I'm submitting a ticket (#468817 in case you can take a look at it) to get a more precise answer since i can't figure what is the way to handle this problem.
  18. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 29 Sep 2011 Link to this post

    I would strongly recommend waiting for our solution for drag-drop between gridview and scheduleview, which will happen in a week. Preparing a sample that demonstrates how to create the functionality on your own is equal to the actual implementation, hence either way you will have to wait one week.

    Greetings,
    Valeri Hristov
    the Telerik team

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

  19. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 04 Oct 2011 Link to this post

    I have changed my application to use the new behavior. My appointment objects are derived from Appointment (i.e. I have a class called WrapperAppointment) so I updated the ScheduleViewToAppointmentConverter to use "typeof(WrapperAppointment)" instead of "typeof(Appointment)".
    I get this exception:


    Message: Unhandled Error in Silverlight Application
    Code: 4004    
    Category: ManagedRuntimeError       
    Message: System.ArgumentNullException: Value cannot be null.
    Parameter name: source
       at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
       at Telerik.Windows.Controls.CollectionExtensions.HaveSameElementsAsSet[T](IEnumerable`1 c1, IEnumerable`1 c2)
       at Telerik.Windows.Controls.DragDropHelper.<GetHighlightSlotsForDrop>d__d.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at Telerik.Windows.Controls.DragDropHelper.GetDestinationSlotsForDrop(DragDropState state, IEnumerable`1 sourceResources, Point relativeDestinationPoint, TimeSpan offsetFromAppointment)
       at Telerik.Windows.Controls.DragDropHelper.GetDestinationSlots(DragDropState state, Point& relativeDestinationPoint, IPayload payload)
       at Telerik.Windows.Controls.DragDropHelper.GetDestinationSlots(DragDropState state, Point relativeDestinationPoint, IPayload payload)
       at Telerik.Windows.Controls.DragDropHelper.GetDestinationSlots(Object data, Point relativeDragPoint)
       at Telerik.Windows.Controls.DragDropHelper.OnDragOver(Object sender, DragEventArgs e)
       at Telerik.Windows.DragDrop.DragEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at Telerik.Windows.RadRoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at Telerik.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RadRoutedEventArgs routedEventArgs)
       at Telerik.Windows.RouteItem.InvokeHandler(RadRoutedEventArgs routedEventArgs)
       at Telerik.Windows.EventRoute.InvokeHandlersImpl(Object source, RadRoutedEventArgs args, Boolean raisedAgain)
       at Telerik.Windows.EventRoute.InvokeHandlers(Object source, RadRoutedEventArgs args)
       at Telerik.Windows.RadRoutedEventHelper.RaiseEvent(DependencyObject element, RadRoutedEventArgs args)
       at Telerik.Windows.DependencyObjectExtensions.RaiseEvent(DependencyObject element, RadRoutedEventArgs e)
       at Telerik.Windows.DragDrop.DragOperation.RaiseDragEvent(RoutedEvent dragEvent, DependencyObject target)
       at Telerik.Windows.DragDrop.DragOperation.OnDragOver(DependencyObject sender)
       at Telerik.Windows.DragDrop.DragOperation.DoDragOver(DependencyObject currentTarget)
       at Telerik.Windows.DragDrop.DragOperation.DragSourcetPreviewMouseMove(Object sender, MouseEventArgs e)
       at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)     

    I am unable to debug where this is happening. I had to update the Telerik controls to fix another bug and now my Scheduler doesn't work! please help.

    UPDATE: Upgrading the Telerik Controls seems to have broken all of the gridviews in our project - the databindings are not working and all the grids are now blank.
  20. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 06 Oct 2011 Link to this post

    Hello,

    I've just answered to the support ticket regarding this issue - we've tried to reproduce it but without much success. Can you send us more details which will help us observe the problem? Thanks

    Greetings,
    Yana
    the Telerik team

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

  21. Ronald
    Ronald avatar
    11 posts
    Member since:
    Sep 2011

    Posted 20 Oct 2011 Link to this post

    Hi Valeri,
    is the example for the drag&drop between the gridview and scheduleview available already?
    It is of interest to us as we would like to implement this in our solution for a customer.
    thanks
    Ronald
  22. samy
    samy avatar
    25 posts
    Member since:
    Sep 2011

    Posted 20 Oct 2011 Link to this post

    There are Internal builds where you can get the latest dev libraries, but i'm not sure it's not linked to a user. Do you see anything when you click the link? If not, ask Valeri, he helped me out tremendously
  23. Ronald
    Ronald avatar
    11 posts
    Member since:
    Sep 2011

    Posted 20 Oct 2011 Link to this post

    I can download the latest internal build 2011.2.1017 but I'm also looking for the documentation or example of the (new) behaviour.
    Thanks
    Ronald
  24. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 21 Oct 2011 Link to this post

    Hello Ronald,

    The drag-drop behavior is still experimental, hence it is not mentioned in our online documentation. When it is ready, we will add several articles. In the meantime, you could read the MS Word document (in the attached to my first post ZIP file) that contains information how to use the behavior.

    All the best,
    Valeri Hristov
    the Telerik team

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

  25. Ronald
    Ronald avatar
    11 posts
    Member since:
    Sep 2011

    Posted 21 Oct 2011 Link to this post

    Hi Valeri,

    thanks for your feedback. I have already used your document and successfully implemented drag&drop between a listbox and RadScheduleView but since you stated in another thread that drag&drop between RadGridview and RadScheduleview is not possible yet untill the 2011 Q3 release I wanted to check if it is possible with the current internal build before I started trying.

    thanks
    Ronald
  26. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 21 Oct 2011 Link to this post

    I have a sample application that demonstrates how to create GridView drag-drop behavior, please find it attached. You need to use the post-SP1 internal builds in order to run it.

    Kind regards,
    Valeri Hristov
    the Telerik team

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

  27. Kajo
    Kajo avatar
    12 posts
    Member since:
    Jun 2012

    Posted 16 Nov 2011 Link to this post

    Hi,
    im using the Version 2011.2.920.1040 of your tools,could you provide an example wich shows
    how to use a custom  DragDropHelper and dragdrop behavior  for drag and drop
    funtionality between RadRibbonButton from the Ribbonview and the ScheduleView?

    regards
  28. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 16 Nov 2011 Link to this post

    Hello,

    Currently we support only the standard ListBox control and RadTreeView, RadGridView and RadScheduleView. We didn't tested with other controls and we cannot guarantee that the drag-drop helper will work correctly.

    Kind regards,
    Valeri Hristov
    the Telerik team

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

  29. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 26 Dec 2011 Link to this post

    how do I set the dragcue in ScheduleViewDragDropBehavior?

    UPDATE -- Nevermind, I just wanted to blank it out and I was able to do that by setting subject to " ".  If subject is empty then the cue defaults to just the word "Appointment", which is what I wanted to get rid of.
  30. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 31 Aug 2012 Link to this post

    I am trying to stop dragging from the scheduleview back to the listbox (or dragging within the listbox).  In the ListBoxDragDropBehavior I can override Drop() so that it does nothing, but the item still disappears from the scheduleview. Is there a way to cancel the drag operation?
  31. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 04 Sep 2012 Link to this post

    Hi Pete,

    You just need to remove the DataConverter from the ListBox ( DataConverterAppointments in the example )- it is responsible for converting appointments back into the objects used in the Listbox.

    Kind regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner