WPF Drag and Drop a custom control to different control types

361 views Asked by At

I'm using WPF to implement an interface to manage groups in a competition. Each group is represented by a custom user control (let's call it GroupControl)

Basically, a GroupControl displays the name of the group (editable Combobox with a list a predefined names), a list of players within the group (Gridview with information such as player name, player number, etc.), and several other data (as Textblocks).

Now, the interface is divided into 2 areas:

  • Area 1 : where I display all the groups.
  • Area 2 : where I'm supposed to work on the groups.

So the idea is to be able to drag and drop (copy, not move) a group from Area 1 to Area 2; but also to be able to drag a group from Area 1 or Area 2 onto another group from Area 2 (to merge it somehow).

I have a first implementation following this tutorial: https://msdn.microsoft.com/en-us/library/vstudio/ms742859%28v=vs.100%29.aspx#Implementing_Drag_And_Drop

It is a very simple solution, and worked very well until I realized the following issue: since every GroupControl intercepts Drag/Drop related events, it prevents me from interacting with the nested controls. For instance, I can't scroll my list of players by clicking and dragging the scrollbar because the MouseMove event is intercepted at the GroupControl level; same goes for the ComboBox which somehow won't display its items unless I remove the MouseMove event.

So, I've started digging found many great Drag and Drop implementations using more complex yet more efficient concepts, especially Adorners or Behaviors.

I read the following: - http://www.zagstudio.com/blog/488#.VYqJFEZ4SdE

It seems to be working very well: I can drag/drop items from an area to another, I can even insert them at a specific position. BUT, I haven't found a way to use this solution to drag/drop a GroupControl onto another GroupControl.

Any help on this matter will be much appreciated. All I want to achieve is being able to interact with the nested controls within the GroupControl.

0

There are 0 answers