ChartView inside ItemsControl Zoom issue When using Mousewheel scroll

3 posts, 1 answers
  1. Sivakumar
    Sivakumar avatar
    29 posts
    Member since:
    Dec 2015

    Posted 06 Jan 2016 Link to this post

    I am using ChartView inside ItemsControl. Everything is working fine.I am facing issue when using mouse-wheel scroll for chart zoom . Issue is itemscontrol scrolling triggered instead of scroll for chart zooming even though my mouse focus on chart.

    My Expected Requirement:

    1.) Do Chart Zoom In/Out  When Mouse focus on chartcontrol.

    2.) Do Item control scrolling when mouse focus on itemscontrol scrollbar.


    I tried few options but those failed.Please help on this..


     Please see attach as well...


  2. Answer
    Peshito avatar
    524 posts

    Posted 08 Jan 2016 Link to this post

    Hello Sivakumar,

    This behavior is caused by the fact that chart's behaviors does not handle mouse wheel events. In order to achieve your expected result please attache to charts MouseWheel event like shown below:
    void chart_MouseWheel(object sender, MouseWheelEventArgs e)
                var pos = e.GetPosition(this.chart);
                ChartPanAndZoomBehavior behav = (ChartPanAndZoomBehavior)this.chart.Behaviors.FirstOrDefault(b => b is ChartPanAndZoomBehavior);
                bool isZoom = behav != null;
                if (!isZoom)
                e.Handled = true;

    This way when the mouse is over the chart and the wheel is being moved forward/backward, the zooming will happen. When the mouse is over the ItemsControl's scrollbar, then only the ItemsControl will scroll.

    Hope it helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Sivakumar
    Sivakumar avatar
    29 posts
    Member since:
    Dec 2015

    Posted 10 Jan 2016 in reply to Peshito Link to this post

    Thanks for your solution.It is working now..
Back to Top