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

Panning with Middle Mouse Button

Thread ID:





143266 Mar 12,2019 09:51 AM UTC Mar 12,2019 10:25 AM UTC WPF 1
Tags: SfChart
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) 
            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) 
            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) 
        public void MouseLeftButtonDown(MouseButtonEventArgs e) 
  <local:SfChartExt Margin="10" x:Name="chart" PanChanging="chart_PanChanging"> 
                <local:ChartZoomPanBehaviorExt EnablePanning="True" EnableMouseWheelZooming="True" /> 
Here we have checked the mouse state and changed button for middle button identification.  
Hope it helps you.  
Muneesh Kumar G.  


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

Live Chat Icon For mobile
Live Chat Icon