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

ListBox drag-drop behavior

29 Answers 558 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Valeri Hristov
Top achievements
Rank 1
Valeri Hristov asked on 04 Aug 2011, 01:44 PM

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

29 Answers, 1 is accepted

Sort by
0
Vadim
Top achievements
Rank 1
answered on 09 Aug 2011, 06:21 AM
It doesn't work with latest internal build 808... :(
0
Valeri Hristov
Telerik team
answered on 15 Aug 2011, 11:53 AM
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 >>

0
Vadim
Top achievements
Rank 1
answered on 19 Aug 2011, 04:32 AM
Are you talking about 815 build that is already available? Or upcoming monday 822 build?
0
Valeri Hristov
Telerik team
answered on 22 Aug 2011, 01:10 PM
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 >>

0
Trude
Top achievements
Rank 2
answered on 23 Aug 2011, 12:59 PM
Where is the build? Now it must be called 2011.2.823.
0
Valeri Hristov
Telerik team
answered on 24 Aug 2011, 08:35 AM
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 >>

0
Vadim
Top achievements
Rank 1
answered on 26 Aug 2011, 04:02 AM
Thank you,
It is working perfectly!
0
Vadim
Top achievements
Rank 1
answered on 29 Aug 2011, 05:26 AM
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;         
        }
0
Valeri Hristov
Telerik team
answered on 29 Aug 2011, 12:17 PM
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 >>

0
Ronald
Top achievements
Rank 1
answered on 09 Sep 2011, 10:50 AM
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
0
Valeri Hristov
Telerik team
answered on 12 Sep 2011, 10:09 AM
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 >>

0
Ronald
Top achievements
Rank 1
answered on 12 Sep 2011, 10:19 AM
Hi Valeri,

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

Kind regards,
Ronald
0
samy
Top achievements
Rank 1
answered on 29 Sep 2011, 12:09 PM
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...
0
Valeri Hristov
Telerik team
answered on 29 Sep 2011, 01:36 PM
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 >>

0
samy
Top achievements
Rank 1
answered on 29 Sep 2011, 02:01 PM
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.
0
Valeri Hristov
Telerik team
answered on 29 Sep 2011, 02:16 PM
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 >>

0
Pete
Top achievements
Rank 1
answered on 04 Oct 2011, 03:46 PM
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.
0
Yana
Telerik team
answered on 06 Oct 2011, 04:04 PM
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 >>

0
Ronald
Top achievements
Rank 1
answered on 20 Oct 2011, 01:58 PM
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
0
samy
Top achievements
Rank 1
answered on 20 Oct 2011, 02:06 PM
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
0
Ronald
Top achievements
Rank 1
answered on 20 Oct 2011, 02:52 PM
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
0
Valeri Hristov
Telerik team
answered on 21 Oct 2011, 09:43 AM
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 >>

0
Ronald
Top achievements
Rank 1
answered on 21 Oct 2011, 10:06 AM
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
0
Valeri Hristov
Telerik team
answered on 21 Oct 2011, 10:22 AM
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 >>

0
Kajo
Top achievements
Rank 1
answered on 16 Nov 2011, 09:07 AM
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
0
Valeri Hristov
Telerik team
answered on 16 Nov 2011, 12:36 PM
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 >>

0
Kjell
Top achievements
Rank 1
answered on 27 Dec 2011, 01:37 AM
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.
0
Pete
Top achievements
Rank 1
answered on 31 Aug 2012, 10:31 AM
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?
0
Yana
Telerik team
answered on 04 Sep 2012, 12:30 PM
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.

Tags
ScheduleView
Asked by
Valeri Hristov
Top achievements
Rank 1
Answers by
Vadim
Top achievements
Rank 1
Valeri Hristov
Telerik team
Trude
Top achievements
Rank 2
Ronald
Top achievements
Rank 1
samy
Top achievements
Rank 1
Pete
Top achievements
Rank 1
Yana
Telerik team
Kajo
Top achievements
Rank 1
Kjell
Top achievements
Rank 1
Share this question
or