How to override the default cursors while interaction in WPF Diagram?
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); } } }
Conclusion
I hope you enjoyed lesrning about how to override the default cursors while interaction in WPF Diagram (SfDiagram).
You can refer to our WPF Diagram feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Diagram documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!