Category / Section
How to activate the trackball on touch?
1 min read
Trackball will be activated once you long-press anywhere on the chart area, but this behavior can be overridable by activating the trackball manually using Show and Hide method of ChartTrackballBehavior.
In the following CustomeTrackballBehavior class, the trackball is activated in OnTouchMove method and deactivated in OnTouchUp method of ChartTrackballBehavior.
XAML
<chart:SfChart.ChartBehaviors> <local:CustomTrackBallBehavior/> </chart:SfChart.ChartBehaviors>
C#
{ CustomTrackBallBehavior trackBall = new CustomTrackBallBehavior(); chart.ChartBehaviors.Add(trackBall); } public class CustomTrackballBehavior : ChartTrackballBehavior { protected override void OnTouchMove(float pointX, float pointY) { Show(pointX, pointY); } protected override void OnTouchUp(float pointX, float pointY) { Hide(); } }