Diagram cursor problem

Hi ,

I want to change the cursor in DragOver() event. So I set

DraggingTool.Source.Diagram.Cursor = Cursors.No;

but the problem is i get an exception saying source as null. i even try to directly set Diagram.Cursor but cursor is not changing. below is the sample code i tried out

protected override void DragOver(Point pt, bool moving, bool copying)
// if dragging from a different Diagram
if (DraggingTool.Source != this)
// don’t consider nodes that are selected, being dragged
Node over = this.Diagram.Panel.FindElementAt(pt,
p => !this.Diagram.SelectedParts.Contains§,
// if it’s not OK to drop here, just change the cursor
var node = over.Data as SymbolData;
if (node.Key != “Rack1”)
//DraggingTool.Source.Diagram.Cursor = Cursors.No;
Diagram.Cursor = Cursors.No;
//DraggingTool.Source.Diagram.Cursor = Cursors.Arrow;
Diagram.Cursor = Cursors.Arrow;
base.DragOver(pt, moving, copying);


A number of tools, but not the DraggingTool, set this.Diagram.Cursor = …

Is this for Silverlight or WPF or XBAP?

wpf ,

Ah, then there’s a real Windows drag-and-drop occurring, so DraggingTool.Source is not involved.

I think you want to override DraggingTool.MayCopyExternal and MayMoveExternal to return false in the cases that you care about.
Returning false from those method(s) will cause DragEventArgs.Effects to be set to DragDropEffects.None.
Or you can do this directly in overrides of DoDragEnter and DoDragOver and DoDrop.