WPF Drag-and-Drop between ListBoxes in different UserControls

This is the structure of my application:

  • Main Window has two ContentControls
  • Each ContentControl has a UserControl
  • Each UserControl has a ListBox

So graphically speaking, the user is presented with a Window with two ListBoxes: one with products and the other a shopping cart.

I want to enable drag-and-drop functionality among these two ListBoxes; i.e products can be dragged into the shopping cart.

I have seen examples of drag-and-drop between ListBoxes on the same window. But is it possible to drag and drop between UserControls?

I have looked at an example; is there a simpler way?

I came across a simple drag drop solution in Expression Blend; I tried searching for it, but in vain.

-------------Problems Reply------------

Drag-and-drop using behaviors is very simple. Download this complete implementation and sample and try it out:

  • ItemsControl Drag Drop Behavior for WPF

It is not clear what is a problem if you've already seen how to do drag-n-drop between listboxes on the same window. Use this code or tell us what's wrong with it.

The good thing about drag-n-drop functionality is that control which starts DND operation doesn't have to know anything regarding control which accepts DND result.

Category:wpf Views:0 Time:2011-02-19

Related post

  • WPF drag and drop from a ListBox that has SelectionMode=Extended 2010-09-22

    I have a ListBox and want the selection-mode to be extended. Also I want have to implement drag and drop functionality. The problem now is, that if the mouse is clicked on a selected item, it will be immediately be selected as single selection instea

  • WPF - Drag'n'drop DataTemplate in listbox up and down 2011-10-05

    I have sophisticated data template of the item in listbox similar to I need to click anywhere inside this item and drag it up or down in the list. Maybe somebody has already implemented such functionality. Thanks! --------------Solutions-------------

  • WPF Drag And Drop DataBinding 2011-03-21

    Hey guys, I'm starting to wrap WPF around my head and I came to a dead end. I have a ListBox that accepts files/folders by drag and drop. I have a Files Class witch contains files properties like "Name", "Thumbnail" [and so on] and a FilesCollection

  • WPF Drag n drop doesn't fire CommanBinding.CanExecute 2009-05-22

    Yes, I know it sounds weird, but it doesn't, the question is why, and if there's a work around. It works with everything, even when you hit PrintScreen or Pause keys, CanExecute fires. So after doing a drag drop, in order to make it fire, you have to

  • WPF drag and drop to DataGrid 2010-03-28

    I have been searching the internet high and low but can't find some examples that can help me. I'm developing an application in wpf, in it I use a DataGrid; each cell has a DataTemplate with and image, in a mosaic style; on the side of the grid I hav

  • Drag'n'Drop sortable Listbox für Windows Phone 7 2010-10-26

    In a Windows Phone 7 application I got a ListBox containing a few items. I want the user to be able to sort the items in the ListBox by just touching and dragging them (on the left part of the ListBox template). How would I implement this? Is there a

  • Can't get simple WPF drag and drop to work 2010-11-22

    For a simple test I want to drag a Button to a TextBox. I can start dragging the Button, but the Drop event is not raised. What am I missing? Xaml: <Window x:Class="DayPlanner.View.DnDTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/prese

  • Wpf: Drag And Drop To A Textbox 2010-11-26

    I've googled this problem, and people have answered similar questions, but for some reason I can't get anything to work. I must have missed something here... At any rate, when I run the following code, the TextBox_DragEnter handler is never called. H

  • WPF Drag and Drop - Get original source info from DragEventArgs 2010-12-23

    I am trying write Drag and Drop functionality using MVVM which will allow me to drag PersonModel objects from one ListView to another. This is almost working but I need to be able to get the ItemsSource of the source ListView from the DragEventArgs w

  • WPF Drag and Drop blocking operations 2011-02-16

    I am working with a WPF application that is using Drag and Drop functionality. The Drag and Drop operation is a blocking operation and is having some negative side effects in my application. I have recently added the use of an adorner to show the ite

  • wpf drag and drop visually select item 2011-05-26

    I'm using drag and drop in my program and it works well. But i'm working with a list of words in a listbox and when I select a word and drag it to another listbox the user don't know anymore which word he chose because the 'visually' selection of the

  • C# Newbie: Change Entity Framework DataBound DataGrid created with WPF drag-and-drop 2011-07-02

    I'm new to C# and I created a WPF GUI using Visual Studio 2010 Ultimate (Windows 7 x64). I used drag-and-drop technology to databind a datagrid to an SQL Server 2008 database table using Entity Framework technology. This all works very well, despite

  • WPF drag and drop files onto TreeView from windows explorer 2011-09-19

    I am trying to make an extremely simple, or so I thought, program to drag and drop a file from the desktop/explorer onto a wpf treeview. The treeview in this example is simple so that I could isolate the drag and drop problem I am having. I have set

  • How to update the position of a drag adorner during WPF drag-n-drop? 2010-01-19

    I'm using an adorner to show a 'ghost' of the element being dragged... var adornerLayer = AdornerLayer.GetAdornerLayer(topLevelGrid); dragAdorner = new DragAdorner(topLevelGrid, itemToDrag); adornerLayer.Add(dragAdorner); dragAdorner.UpdatePosition(e

  • WPF Drag and Drop - PreviewMouseMove + PreviewMouseLeftButtonDown cant work together? 2011-02-16

    If I am using two event handlers, PreviewMouseLeftButtonDown and PreviewMouseMove. The problem I am having is that everything is working fine when PreviewMouseLEftButtonDown is triggered, but since it is a drag and drop operation, the left button sta

  • How to stop WPF drag and drop from locking dropped file 2011-02-28

    I have a drag and drop application (which allows users to organize their files) that takes files. The app keeps a list of strings that corresponds to the files, but it does not need access to the files themselves. The problem is that the program lock

  • Drag and drop between ListBox items and Grid cells in WPF? 2010-01-27

    Hi There is a list box with some items in it. Also there is a grid with 3x3 matrix. The user will be dragging an item and dropping on one the cells of grid. Most of the samples I found are about dragging-dropping from one listbox to another listbox.

  • wpf drag and drop setter invoke in source 2011-04-13

    I have a textbox like this: <TextBox x:Name="txtCondition" Text="{Binding Path=Name ,Mode=TwoWay}"/> When I select the text in this textbox and drag it to somewhere the setter of the binded property in this textbox is automatically called, but

  • WPF drag and drop and data types 2011-04-20

    Maybe my question is nooby, but i couldn't find an answer... i have a drag&drop app in wpf... i have the built the interface and i want to add functionality... what i need to do, is when i drop an item in my designer area, to get the type of the

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.202 (s). 11 q(s)