We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to override the default cursors while interaction in WPF Diagram (SfDiagram)?

Platform: WPF |
Control: SfDiagram

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.
  • CursorTo 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);
    }
  }
}

 

A picture containing game, table

Description automatically generated

View Sample in GitHub

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile