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

How to drag and drop between two instances of the same application?

1 Answer 308 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 04 Aug 2014, 12:42 PM
My application contains a RadListbox and I'd like to drag and drop items in this RadListBox from one instance of my application to another instance. How can I accomplish this?

It's similar to wanting the CustomDragVisualStyle_WPF example to support drag and drop between instances instead of just allowing drag and drop within one instance.

I got it working with copy/paste buttons, but I also want to support drag and drop.

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 07 Aug 2014, 11:17 AM
Hi Martin,

What I can suggest you would be to check the following article which explains how to achieve the desired:
http://wpf.2000things.com/2012/12/05/705-dragging-a-custom-object-using-serialization-as-format/

You will need to add the [Serializable] attribute to your custom object and using the DragDropManager in the DragInitialize method to create new Serializable DataObject as shown below:

private void OnDragInitialize(object sender, DragInitializeEventArgs e)
{
    e.AllowedEffects = DragDropEffects.All;
    e.Data = new DataObject(DataFormats.Serializable, new Customer { FullName = "Customer" });
    e.Handled = true;
}

Afterwards on Drop in the second instance of the Application you can get the object the following way:

private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
    var data = (e.Data as DataObject).GetData(DataFormats.Serializable) as Customer;
}

Hope this will help you to achieve the required.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
DragAndDrop
Asked by
Martin
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or