ChartTrackBallBehavior Binding

Hi,

Is it possible to bind attributes on ChartTrackBallBehavior?

I want to make the trackball customizable at runtime:


<syncfusion:ChartTrackBallBehavior ShowLine="{Binding ChartSettings.TrackballLineVisible}" x:Name="ChartTrackball" />

The "ChartSettings.TrackballLineVisible" is a bool. But the binding does not work (Line can not be enabled/disabled at runtime). At the same time the binding for the label on the PrimaryAxis does work (also bool).

<syncfusion:DateTimeAxis x:Name="PrimaryAxis" ShowTrackBallInfo="{Binding ChartSettings.TrackballTooltipDateTimeAxis}"/>

Is it somehow not possible to make a binding on ChartTrackBallBehavior?

(Even if i bind both on the same bool the ShowTrackBallInfo on the axis works but the ShowLine on the ChartTrackBallBehavior does not)

Regards, Lukas R.

1 Reply

MK Muneesh Kumar G Syncfusion Team March 16, 2018 10:07 AM UTC

Hi Lukas, 
 
Thanks for using Syncfusion products. 
 
We would like to inform you that, the ChartTrackBallBehavior is an object, which is not directly added to the visual tree. So that, we are unable to inherit DataContext from its parent control.  
  
However, we can resolve this problem by defining the view model instance in StaticResources, and can bind the corresponding property of view model to ShowLine property of ChartTrackBallBehavior. Please refer the below codes,  
 
Code snippet [XAML] : 
  
<Grid.Resources> 
            <local:ViewModel x:Key="ViewModel"/> 
        </Grid.Resources> 
 
<chart:SfChart Margin="10" x:Name="chart" DataContext="{StaticResource ViewModel}"> 
 
            <chart:SfChart.Behaviors> 
                <chart:ChartTrackBallBehavior ShowLine="{Binding    ShowHideTrackballLine,Source={StaticResource ViewModel}}"/> 
            </chart:SfChart.Behaviors> 
 
        </chart:SfChart> 
 
We have prepared a simple sample based on this and it can be downloaded from below link. 
 
 
Please let us know if you have any queries.  
 
Regards, 
Muneesh Kumar G. 
 


Loader.
Up arrow icon