This code with custom cursor loaded from resource works for me.
private Cursor customCursor = null;
private void Element_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DataObject data = new DataObject(DataFormats.Text, <data>);
DragDrop.DoDragDrop((DependencyObject)e.Source, data, DragDropEffects.Copy | DragDropEffects.Move);
}
private void Element_GiveFeedback(object sender, GiveFeedbackEventArgs e)
{
if (e.Effects == DragDropEffects.Copy || e.Effects == DragDropEffects.Move)
{
if (customCursor == null)
{
var rs = Application.GetResourceStream(new Uri("move.cur", UriKind.Relative));
customCursor = new Cursor(rs.Stream);
}
e.UseDefaultCursors = false;
Mouse.SetCursor(customCursor);
}
else
e.UseDefaultCursors = true;
e.Handled = true;
}
Holding the Ctrl
key during a drag and drop operation relates to copying the item and therefore you need to allow the DragDropEffects.Copy.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…