How to trigger SelectionChanging event with a right click?

Hi,

It seems that this even only fires off with a left-click. is it possible to do this with a right click?



1 Reply

YP Yuvaraj Palanisamy Syncfusion Team April 30, 2022 05:33 AM UTC

Hi Lorenzo,


You can achieve your requirement of “Fire the SelectionChanging event of SfChart when right click on the segment” with the help of call onMouseLeftButtonDown in the OnMouseRightButtonDown override method and call onMouseLeftButtonUp in the OnMouseRightButtonUp override method as per the below code example.


CodeSnippet:

<local:ChartExt x:Name="chart" SelectionChanging="chart_SelectionChanging">

. . .

 

  <chart:SfChart.Behaviors>

      . . .

      <chart:ChartSelectionBehavior EnableSegmentSelection="True"/>

  </chart:SfChart.Behaviors>

 

</local:ChartExt>


private void chart_SelectionChanging(object sender, ChartSelectionChangingEventArgs e)

{

 

}


public class ChartExt : SfChart

{

    protected override void OnMouseRightButtonDown(MouseButtonEventArgs

    {

        base.OnMouseRightButtonDown(e);

        this.OnMouseLeftButtonDown(e);

      

    }

 

    protected override void OnMouseRightButtonUp(MouseButtonEventArgs e

    {

        base.OnMouseRightButtonUp(e);

        this.OnMouseLeftButtonUp(e);

    }

}


We have attached the sample for your reference, please find the sample from the below attachment.


Please let us know if you have further assistance.


Regards,

Yuvaraj.


Attachment: ChartSample_710770dc.zip

Loader.
Up arrow icon