ChartTrackBallBehavior, move the ball only on mouse click

Thread is closed for posting
2 posts, 0 answers
  1. sp09
    sp09 avatar
    1 posts
    Member since:
    Mar 2015

    Posted 14 Apr 2015 Link to this post


    I am new to telerik controls. I am using ChartTrackBallBehavior on RadCartesianChart. By default the trackball moves with the mouse motion on the chart. Instead of it, I want the trackball to move only on mouse left click on chart. How can I disable the trackball movement with mouse left/right motion event?

  2. Martin Ivanov
    Martin Ivanov avatar
    2580 posts

    Posted 17 Apr 2015 Link to this post

    Hello Sonam,

    You can achieve your requirement by using the Position property of the TrackBallBehavior. Basically you can subscribe for the MouseLeftButtonDown event of the chart and inside its handler get the current mouse position and set it as the trackball's Position. However, this won't prevent the moving of the trackball on mouse move. To resolve this you can save the previously clicked position and set it in the PositionChanging event handler of the behavior. Here is an example in code:
    private Point currentPosition;
    private void ChartTrackBallBehavior_PositionChanging(object sender, TrackBallPositionChangingEventArgs e)
        e.NewPosition = currentPosition;
    private void chart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        currentPosition = e.GetPosition(this.chart);
        this.trackBallBehavior.Position = currentPosition;

    Please give this approach a try and let me know if it works for you.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top