TrackBallBehavior on right click

Hello, I am using SfChart with custom TrackBall ControlTemplate. I have to add additional values into the template which slows down the rendering process. The trackball is not always desired to be shown. How can I show the trackball only when the mouse right/middle button is clicked? Left click is already used for zooming/panning.

5 Replies

MK Muneesh Kumar G Syncfusion Team July 30, 2018 12:37 PM UTC

Hi Daniel,  
  
Thanks for using Syncfusion products.  
 
We have analysed your requirement and you can achieve this by using PositionChanging event in ChartTrackBallBehavior and checking mouse state as per the below code snippet.  
 
Code snippet [XAML]: 
  <chart:SfChart.Behaviors> 
                <chart:ChartTrackBallBehavior PositionChanging="ChartTrackBallBehavior_PositionChanging" /> 
            </chart:SfChart.Behaviors> 
 
Code snippet [C#]: 
   private void ChartTrackBallBehavior_PositionChanging(object sender, PositionChangingEventArgs e) 
        { 
            if (Mouse.RightButton != MouseButtonState.Pressed) 
                e.Cancel = true; 
        } 
 
Please refer the below user documentation for more details.  
 
 
Please let us know if you have any queries.  
  
Thanks,  
Muneesh Kumar G. 



DA Daniel July 31, 2018 10:07 AM UTC

Thank you, however, now when I stop holding the right button, the tooltip is still shown. How can I hide it afterwards?


MK Muneesh Kumar G Syncfusion Team August 1, 2018 09:40 AM UTC

Hi Daniel,   
   
You can hide the trackball tooltip by calling internal ClearItems method in SfChart’s MouseRightButtonUp event as per the below code snippet.   
  
Code snippet [XAML]:  
     <chart:SfChart x:Name="chart" MouseRightButtonUp="Chart_MouseRightButtonUp"> 
 
            <chart:SfChart.Behaviors> 
                <chart:ChartTrackBallBehavior x:Name="behavior" PositionChanging="ChartTrackBallBehavior_PositionChanging" /> 
            </chart:SfChart.Behaviors> 
.. 
        </chart:SfChart> 
  
Code snippet [C#]:  
   private void Chart_MouseRightButtonUp(object sender, MouseButtonEventArgs e) 
        { 
            behavior.GetType().GetMethod("ClearItems", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(behavior, null); 
 
        } 
  
Please let us know if you have any queries.   
   
Thanks,   
Muneesh Kumar G.  
 



DA Daniel replied to Muneesh Kumar G August 1, 2018 09:58 AM UTC

Hi Daniel,   
   
You can hide the trackball tooltip by calling internal ClearItems method in SfChart’s MouseRightButtonUp event as per the below code snippet.   
  
Code snippet [XAML]:  
     <chart:SfChart x:Name="chart" MouseRightButtonUp="Chart_MouseRightButtonUp"> 
 
            <chart:SfChart.Behaviors> 
                <chart:ChartTrackBallBehavior x:Name="behavior" PositionChanging="ChartTrackBallBehavior_PositionChanging" /> 
            </chart:SfChart.Behaviors> 
.. 
        </chart:SfChart> 
  
Code snippet [C#]:  
   private void Chart_MouseRightButtonUp(object sender, MouseButtonEventArgs e) 
        { 
            behavior.GetType().GetMethod("ClearItems", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(behavior, null); 
 
        } 
  
Please let us know if you have any queries.   
   
Thanks,   
Muneesh Kumar G.  
 


Thank you, everything is working now.


MK Muneesh Kumar G Syncfusion Team August 1, 2018 10:38 AM UTC

Hi Daniel, 

Thanks for the update.

We are glad to know that the given solution works. Please let us know if you need any further assistance.

Thanks,
Muneesh Kumar G.

Loader.
Up arrow icon