Hi, I need some help with WPF's drag and drop. I have a ListView list
composed of filenames from a selected directory and I would like to add the
drag and drop feature into my list so I can drag and drop the filenames into
a TreeView list using the left mouse button. The drag and drop I created
only works if I click and hold down my left mouse button, move the mouse
pointer off the list of filename, and then click and hold the right mouse
button while still holding down the left mouse button. In essence I need to
hold down both my mouse buttons to get it to work. Furthermore, if I click
and hold down my left mouse button to select an item from my filename list
and move the cursor over another item in the list, my selected item
changes to the items my mouse pointer is hovering over.
How can I fix the drag and drop in such a way that it allows me to select an
item from the filename list and use only the left mouse button to drag the
filename to my desired location? Also, is there a way to lock the selector
when I have my mouse button held down so my selected item don't change to
the new item my mouse pointer is hovering over?
Here are the XAML and C# codes for the drag and drop:
<TreeView Name="tree" Header="tree" AllowDrop="True" Drop="tree_Drop"
<ListView Name="files" MouseDown="list_MouseDown">
ListView list ...
foreach( string s in Directory.GetFiles(filePath) )
private void (object sender, MouseButtonEventArgs e)
ListView lv = (ListView)sender;
private void tree_DragEnter(object sender, DragEventArgs e)
e.Effects = DragDropEffects.Copy;
e.Effects = DragDropEffects.None;
private void tree_Drop(object sender, DragEventArgs e)