I'm a newbie to programming, so forgive me if the question is silly.
I have graph which I zoom(using mouse wheels) and pan(using left mouse). I want to stop the panning, if it goes bellow 0 on time scale(X-axis).
I used "PannedXYEventArgs" and "BeforePanningXYEventArgs event. That stopped the panning bellow 0.
But it is zooming instead when I pan near zero(I expect it to not pan). It is supposed to "only pan" with left mouse button. What am i missing?
Problem with panning
Moderator: Queue Moderators
-
- Posts: 3
- Joined: Fri Aug 03, 2018 1:18 pm
Re: Problem with panning
Hi Anjali,
Yes, ideally it should Pan only and not zoom if you have set ViewXY.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.Pan;
So, in your case it might me more than that
I tried to replicate your problem like below and it was working fine for me:
public partial class MainWindow : Window
{
private LightningChartUltimate _lcu;
public MainWindow()
{
InitializeComponent();
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
_lcu = new LightningChartUltimate();
MainGrid.Children.Add(_lcu);
_lcu.ViewXY.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.Pan;
_lcu.ViewXY.BeforePanning += ViewXY_BeforePanning;
}
private void ViewXY_BeforePanning(object sender, Arction.Wpf.Charting.Views.ViewXY.BeforePanningXYEventArgs e)
{
if(e.XRanges.First().NewMin < 0)
{
e.Cancel = true;
}
}
}
If you are doing something else or more, please update above code or you can send your code in a small project to me at [email protected]
Thanks,
Nitin Shrivastava
Yes, ideally it should Pan only and not zoom if you have set ViewXY.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.Pan;
So, in your case it might me more than that
I tried to replicate your problem like below and it was working fine for me:
public partial class MainWindow : Window
{
private LightningChartUltimate _lcu;
public MainWindow()
{
InitializeComponent();
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
_lcu = new LightningChartUltimate();
MainGrid.Children.Add(_lcu);
_lcu.ViewXY.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.Pan;
_lcu.ViewXY.BeforePanning += ViewXY_BeforePanning;
}
private void ViewXY_BeforePanning(object sender, Arction.Wpf.Charting.Views.ViewXY.BeforePanningXYEventArgs e)
{
if(e.XRanges.First().NewMin < 0)
{
e.Cancel = true;
}
}
}
If you are doing something else or more, please update above code or you can send your code in a small project to me at [email protected]
Thanks,
Nitin Shrivastava