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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Panning with Middle Mouse Button

Thread ID:

Created:

Updated:

Platform:

Replies:

143266 Mar 12,2019 09:51 AM UTC Mar 12,2019 10:25 AM UTC WPF 1
loading
Tags: SfChart
John
Asked On March 12, 2019 09:51 AM UTC

How can I do that ?

Muneesh Kumar G [Syncfusion]
Replied On March 12, 2019 10:25 AM UTC

Hi xmen, 
 
Greetings from Syncfusion, we have analyzed your requirement and you can achieve this by extending SfChart and ChartZoomPanBehavior then overriding MouseDown and MouseUp event as per the below code snippet.  
 
Code snippet 
public class SfChartExt : SfChart 
    { 
        protected override void OnMouseDown(MouseButtonEventArgs e) 
        { 
            base.OnMouseDown(e); 
 
            if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed) 
                foreach (var behavior in Behaviors) 
                { 
                    if (behavior is ChartZoomPanBehaviorExt) 
                        (behavior as ChartZoomPanBehaviorExt).MouseLeftButtonDown(e); 
                } 
        } 
 
        protected override void OnMouseUp(MouseButtonEventArgs e) 
        { 
            base.OnMouseUp(e); 
 
            if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Released) 
                foreach (var behavior in Behaviors) 
                { 
                    if (behavior is ChartZoomPanBehaviorExt) 
                        (behavior as ChartZoomPanBehaviorExt).MouseLeftButtonUp(e); 
 
                } 
        } 
    } 
 
    public class ChartZoomPanBehaviorExt : ChartZoomPanBehavior 
    { 
        public void MouseLeftButtonUp(MouseButtonEventArgs e) 
        { 
            OnMouseLeftButtonUp(e); 
        } 
 
        public void MouseLeftButtonDown(MouseButtonEventArgs e) 
        { 
            OnMouseLeftButtonDown(e); 
        } 
    } 
 
 
  <local:SfChartExt Margin="10" x:Name="chart" PanChanging="chart_PanChanging"> 
 
            <chart:SfChart.Behaviors> 
 
                <local:ChartZoomPanBehaviorExt EnablePanning="True" EnableMouseWheelZooming="True" /> 
 
            </chart:SfChart.Behaviors> 
            .. 
 
        </local:SfChartExt> 
 
Here we have checked the mouse state and changed button for middle button identification.  
 
 
Hope it helps you.  
 
Thanks, 
Muneesh Kumar G.  
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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

;