Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

drag and drop usercontrols in a wpf unable to perform.
i have 2 user controls on wpf form . i would like to drag these usercontrols on to a canvas in the same app. can ny one correct my code.


C#
void UserControl1_MouseMove(object sender, MouseEventArgs e)
{
if(e.LeftButton==MouseButtonState .Pressed)
DragDrop .DoDragDrop(this ,new DataObject("myformat",this),DragDropEffects .Move );
}

void UserControl2_MouseMove(object sender, MouseEventArgs e)
{
if(e.LeftButton==MouseButtonState .Pressed)
DragDrop .DoDragDrop(this ,new DataObject("myformat",this),DragDropEffects .Move );
}		

void Canvas1_Drop(object sender, DragEventArgs e)
{
var control=e.Data .GetData(typeof(UserControl))as UserControl;	 
canvas1 .Children .Add(control);
}
Posted
Updated 5-Jul-11 1:47am
v3

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900