Category / Section
How to override the default cursors while interaction in WPF Diagram (SfDiagram)?
3 mins read
The default cursors can be modified by overriding the virtual method SetCursor() of the WPF Diagram (SfDiagram) class. The SetCursor() method takes the SetCursorArgs as an argument that is used to know the objects under the mouse cursor when modifying the cursors of them.
- Source – To know the object on which item the mouse is interacting.
- Action – To know the action tool of the element.
- SourceType – To know the parent element of the object.
- ControlPointType – To know the control point of the object.
- Cursor – To customize the cursor of the object.
XAML
<local:CustomClass PortVisibility="Visible" x:Name="diagram"/>
C#
public class CustomClass : SfDiagram { protected override void SetCursor(SetCursorArgs args) { if (args.Source is INode) { args.Cursor = Cursors.No; } else if (args.Source is IConnector) { args.Cursor = Cursors.Hand; } else if (args.Source is IPort) { args.Cursor = Cursors.SizeAll; } else { base.SetCursor(args); } } }