)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the Selection behavior in Diagram

Platform: WPF |
Control: SfDiagram |
Published Date: February 22, 2017 |
Last Revised Date: November 29, 2019

By default, the selection can be done in PointerUp in SfDiagram. SfDiagram provides support to customize the Selection behavior that allows selection in PointerDown. This can be achieved by overriding the PointerSelection method in Selector class of SfDiagram. In that, the Selection method is used to select/unselect the Node and Connector in the PointerDown Event. The ClearSelection method is used to clear the selection when the argument source become the SfDiagram. The following code example represents this.

 

C#

public class CustomSelector : Selector
    {       
        //Method to decide whether the Selection should be done in PointerDown.
        protected override void PointerSelection(PointerSelectionArgs args)
        {
            if (args.PointerMode == PointerMode.Down)
            {
 
                Selection(element: args.Source);
 
                if (args.Source is SfDiagram)
                {
                    ClearSelection(Element: args.Source);
                }
            }
        }
    }

 

And, you need to return this Selector(CustomSelector) class in the GetSelectorForItemOverride() method of Diagram(CustomDiagram). Refer to the following code example.

C#

public class CustomDiagram : SfDiagram
    {        
        //Method to return the selector for diagram.
        protected override Selector GetSelectorForItemOverride(object item)
        {
            //Assigning custom selector to the diagram.
            CustomSelector selector = new CustomSelector();
            return selector;
        }
      
    }

 

You can download the sample from the following link. https://www.syncfusion.com/downloads/support/directtrac/general/ze/Selection_Override-529725195.zip

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Lou
Aug 30, 2018

This method does not appear to exist in SfDiagram.

Reply

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
Live Chat Icon