I have a radgridview that contains items of class A (not deriving from appointment). I want to be able to drag one row at a time into a scheduleview control where it will turn into an appointment at the desired location.
I tried following the explanations on the pinned thread in this forum but i'm hitting the following problems:
- i can't find a DragDropBehavior class, only a DragDropBehavior<T, ST> and the documentation doesn't give any indication about what classes this DragDropBehavior should work with
- i tried finding the ListBoxDragDropBehavior class to follow the example that is said to "[snip] provides drag-drop capabilities for standard ListBox controls" in the doc but i can't find it in the classes
Are there pointers about implementing drag from arbitrary controls bound to arbitrary classes and drop to the ScheduleView to create appointments?
16 Answers, 1 is accepted

Since i wanted to drag from a gridview bound to arbitrary entities (not appointments) into a schedule view, i decided to create a GridViewDragDrop
public
class
GridViewDragDrop: DragDrop<GridViewDragDropHelper, GridViewDragDropBehavior, GridViewDragDropState>
{
However, when i try to create the GridViewDragDropHelper, i can't go any further since it must implement an internal abstract method, GetDraggedItems. Since i obviously can't plug in the Telerik namespace, i'm stuck. Apart from you changing the method signature, what's the way of handling this? Should i try another/older way of managing the drag and drop between these two controls?
We are currently working on a RadGridView drag-drop behavior, that most probably will be available in the internal build from the second week of October. I am afraid that currently you cannot create a custom drag-drop behavior based on our base classes. We will do our best to open the API with the Q3 2011 release in November.
Best wishes,
Valeri Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Regards,Chris
The DragDropBehavior for RadGridView will not be built-in even with the Q3 release, but the prototype version is available as a sample (attached). If you don't want to do something more complex than drag grid rows to other controls or just reorder rows, the sample will be enough and you don't have to understand the classes in the GridView folder, which are fairly simple, though. We are open for feedback, so if you have suggestions or you find something that does not work as expected, please drop us a line, we will appreciate it.
You need to use the latest internal build of Q2 2011 in order to compile the application.
Regards,
Valeri Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

In the previous versions this was done by setting the dragcue property on the DragDropQueryEventArgs:
private static void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
if (e.Options.Status == DragStatus.DragQuery)
{
if (e.Options.DragCue == null)
{
var sourceControl = e.Options.Source;
var viewModel = (sourceControl.DataContext as MyViewModel);
if (viewModel == null)
{
return;
}
var customAppointment = (CustomAppointment)viewModel.SelectedVisit;
var dragCue = new DragVisualCue();
dragCue.Height = 25;
dragCue.Width = 100;
dragCue.Template = (ControlTemplate)Application.Current.Resources["VisitDragCue"];
dragCue.DataContext = sourceControl.DataContext;
e.Options.DragCue = dragCue;
RadDragAndDropManager.DragCueOffset = GetEffectiveDragOffset(e.Options);
e.Options.Payload = new ScheduleViewDragDropPayload(viewModel.Visits, new List<
IOccurrence
> { viewModel.SelectedVisit });
}
}
else if (e.Options.Status == DragStatus.DragCancel || e.Options.Status == DragStatus.DragComplete)
{
RadDragAndDropManager.DragCueOffset = new Point();
}
e.QueryResult = true;
e.Handled = true;
}
RadGridView has built-in drag-drop provider from Q3 2011 SP1 (2011.3.1220). I would advise using the built-in functionality instead of the attached sample if you could upgrade. Note that the classes are not mapped to the telerik URI namespace yet and you should add a full xmlns declaration to the Telerik.Windows.DragDrop.Behaviors namespace in Telerik.Windows.Controls.GridView assembly.
The drag visual is customized using a DragVisualProvider. We have a couple of standard implementations: Default (shows a small summary element), Empty (only the mouse cursors are changed), Screenshot (makes a skreenshot of the dragged objects) that can be used like this:
http://www.telerik.com/help/silverlight/dragdropmanager-behaviors-customizingdragvisual.html
You could also create a special provider that returns a visual of your choice by implementing IDragVisualProvider in a class. I don't have an example and it should be straight-forward implementation, but if you have questions, please don't hesitate to ask.
Greetings,
Valeri Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Could you explain how to use the built-in functionality please as I have tried removing the custom behavior from the demo app but it doesn't work.
<
telerik:RadGridView
telerik:DragDropManager.AllowDrag
=
"True"
ItemsSource
=
"{Binding Appointments1}"
SelectionMode
=
"Single"
>
<!--<
telerik:RadGridView.RowStyle
>
<
Style
TargetType
=
"telerik:GridViewRow"
>
<
Setter
Property
=
"drag:DragDropManager.AllowDrag"
Value
=
"True"
/>
</
Style
>
</
telerik:RadGridView.RowStyle
>-->
<!--
<
gridDrag:GridViewDragDrop.Behavior
>
<
gridDrag:GridViewDragDropBehavior
/>
</
gridDrag:GridViewDragDrop.Behavior
>
-->
<
gridDrag:GridViewDragDrop.DataConverter
>
<
local:DataConverterAppointments
/>
</
gridDrag:GridViewDragDrop.DataConverter
>
<
gridDrag:GridViewDragDrop.DragVisualProvider
>
<
dragDropBehaviors:ScreenshotDragVisualProvider
/>
</
gridDrag:GridViewDragDrop.DragVisualProvider
>
</
telerik:RadGridView
>
I have prepared sample project that illustrate how to use the build-in behaviors. In their nature they similar to the cusom ones from the project. You can still inherit or replace the visual provider to provide your own as described in the previopus post.
Please, have a look at the sample and let us know if you have any further questions.
Tsvyatko
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I tried with your attached sample to drag from RadGridView and drop into radscheduledview
in SL5 with latest RadControl,but without sucecss.
Your attached sample app shows wpf version but broken for SL version,however I placed
all help classes as shown in sample project but dragging is not shown at all.
Could you pls provide another SL5 sample project ?
Thank you in advance.
Kang
You can find the example Valeri Hristov provided earlier updated for Silverlight 5.
All the best, Ivo
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

For my project, radgridview is bound to custom business object. During drag and drop operation, based on the values in the custome business object, like to validate whether drop can be allowed. If allowed, like to build appointment object because the dragged object is not of appointment Type.
In the ConvertDraggedData, method in ScheduleViewDragDropBehavior class, can I create new appointment object and return?
I tried, but it is not working.
I have attached an example showing how to implement drag and drop in both directions and with different datasources for RadGridView and RadScheduleView. You can use it as a base and override CanDrop method to implement the custom logic.
Hope this helps.
Greetings,
Yana
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

The item is removed from the GridView in DragDropCompleted event, so in order to change this behavior, you just need to override DragDropCompleted with empty definition:
namespace
Telerik.Windows.Controls.GridView
{
/// <summary>
///
/// </summary>
public
class
GridViewDragDropBehavior : DragDropBehavior<Telerik.Windows.DragDrop.Behaviors.DragDropState>
{
/// <summary>
/// Initializes a new instance of the <see cref="GridViewDragDropBehavior"/> class.
/// </summary>
public
GridViewDragDropBehavior()
{
}
public
override
void
DragDropCompleted(Windows.DragDrop.Behaviors.DragDropState state)
{
//base.DragDropCompleted(state);
}
}
}
Greetings,
Yana
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.


I am dragging items from radgridview to radscheduleview. In the canDrop event, was making a synchronous database call to save the changes to the database; This database call is taking around 5 to 8 seconds; because of this, can drop event is getting raised multiple times.
SO I removed the database call and kept in appointment created event handler, again same issue. This event is getting raised again and again.
Please suggest the solution.