Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF C# Drag and Drop Drag Element as Cursor
    text
    copied!<p>i am new to programming and i am trying to do a drag and drop here , i can drag and drop now but the custom cursor to drag and drop is ugly , how do i drag the element that i am draging as the cursor? i search online and found some mentioning about adorner but i don't even understand the codes . Is there any simple or simplified and better way to do this?</p> <p>I have this code here that i can drag and drop ( i dynamically created textbox and label in a for loop , i retrieve the text and append it to label from a database :</p> <pre><code> TextBox tbox = new TextBox(); tbox.Width = 250; tbox.Height = 50; tbox.AllowDrop = true; tbox.FontSize = 24; tbox.BorderThickness = new Thickness(2); tbox.BorderBrush = Brushes.BlanchedAlmond; tbox.PreviewDrop += new DragEventHandler(tbox_Drop); if (lstQuestion[i].Answer.Trim().Length &gt; 0) { wrapPanel2.Children.Add(tbox); answers.Add(lbl.Content.ToString()); MatchWords.Add(question.Content.ToString(), lbl.Content.ToString()); } Dictionary&lt;string, string&gt; shuffled = Shuffle(MatchWords); foreach (KeyValuePair&lt;string, string&gt; s in shuffled) { Label lbl = new Label(); lbl.Content = s.Value; lbl.Width = 100; lbl.Height = 50; lbl.FontSize = 24; lbl.DragEnter += new DragEventHandler(lbl_DragEnter); // lbl.MouseMove += new MouseEventHandler(lbl_MouseMove); lbl.MouseDown +=new MouseButtonEventHandler(lbl_MouseDown); dockPanel1.Children.Add(lbl); } </code></pre> <p>I am dragging labels(drag target) into textbox( drop target ) , which event should i use and how i write the events to set the drag cursor to the labels that i am dragging?</p> <p>Here are the events i have used atm :</p> <pre><code> private void tbox_Drop(object sender, DragEventArgs e) { MessageBox.Show("Are you sure ? Wrong don't blame me "); (sender as TextBox).Text = string.Empty; } private void lbl_DragEnter(object sender, DragEventArgs e) { if (sender == e.Source) { e.Effects = DragDropEffects.None; } } </code></pre> <p>Any solutions or help is appreciated , I've seen adorner , its way too complicated for me to understand to implement it . Looking for a simple and simplified way to do this .</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload