Trying to enable the Zoom Toolbar in an SfChart at runtime via binding.

Neither method of binding works. Visual studio 2015 example project attached. Version 18.3.0.35

Bind directly to checkbox IsChecked property:


or binding to property belonging to viewmodel:




1 Reply 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team December 21, 2020 02:44 PM UTC

Hi Zeljko Lazic, 
 
Greetings from Syncfusion. 
 
We have analyzed your query and we have achieved your requirement by using the below code snippet. 
 
#Solution 1 : Binding directly to CheckBox IsChecked property 
<CheckBox x:Name="checkBox" IsChecked="{Binding ShowToolbar}">Turn on zoom toolbar</CheckBox> 
 
<syncfusion:SfChart Grid.Row="1"> 
    <syncfusion:SfChart.Behaviors> 
        <syncfusion:ChartZoomPanBehavior EnableZoomingToolBar="{Binding Path=IsChecked, Mode=TwoWay, Source={x:Reference checkBox}}"> 
        </syncfusion:ChartZoomPanBehavior> 
    </syncfusion:SfChart.Behaviors> 
</syncfusion:SfChart> 
 
#Solution 2:  Binding ViewModel property via Checkbox DataContext 
<CheckBox x:Name="checkBox" IsChecked="{Binding ShowToolbar}">Turn on zoom toolbar</CheckBox> 
 
<syncfusion:SfChart Grid.Row="1"> 
    <syncfusion:SfChart.Behaviors> 
        <syncfusion:ChartZoomPanBehavior EnableZoomingToolBar="{Binding Path=DataContext.ShowToolbar, Mode=TwoWay, Source={x:Reference checkBox}}"> 
        </syncfusion:ChartZoomPanBehavior> 
    </syncfusion:SfChart.Behaviors> 
</syncfusion:SfChart> 
 
Also, we have attached the sample for your reference. Please find the sample form the below link. 
 
  
Please let us know if you have any concern. 
 
Regards, 
Yuvaraj.

Marked as answer
Loader.
Up arrow icon