We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Is there any event for checkbox visibility changed in legenditem and we can subscribe to it.

Is there any event for checkbox visibility changed in legenditem and we can subscribe to it.

3 Replies

LA Lavanya Anaimuthu Syncfusion Team February 7, 2020 08:57 AM UTC

Hi Ranjithkumar caliaperoumal,  
  
Greetings from Syncfusion.  
  
You can achieve this requirement using the MouseDown event in ChartLegend. For more details you can refer the following KB to achieve this,  

However, another way is to bind a property to IsSeriesVisible property of a series to get the notification. 
 
  
You can enable legend item only for the primary series and then bind the same boolean property (the property which holds the state of series visibility) from view model to all the associated series IsSeriesVisible property. By this way, when the primary series is clicked, all the associated series visibility will also be toggled.  
  
Please let us know if need any further assistance on this.  
  
 
Thanks, 
Lavanya A. 
 



HS Harsh Shah February 24, 2020 05:23 AM UTC

Hii,
I have a solution
XAML code
<Grid Name="LayoutRoot">
<Grid.Resources>

    <Style x:Key="CategoryLegendItem" TargetType="DVC:LegendItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DVC:LegendItem">
                    <StackPanel Orientation="Horizontal">
                        <CheckBox VerticalAlignment="Center" IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Owner.Visibility, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter1}}" Margin="0,0,3,0" />
                        <Rectangle Width="8" Height="8" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" Margin="0,0,3,0" />
                        <DV:Title VerticalAlignment="Center" Content="{TemplateBinding Content}" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Grid.Resources>
<DVC:Chart Name="mcChart"  >
</DVC:Chart>
C# 
ColumnSeries ser = new ColumnSeries { Title = kvpNuclide.Value, IndependentValueBinding = new Binding("Key"), DependentValueBinding = new Binding("Value") };
                ser.ItemsSource = null;
                ser.ItemsSource = listRelease;
                ser.DataPointStyle = columnStyleAqua;
                ser.LegendItemStyle = (Style)LayoutRoot.Resources["CategoryLegendItem"];
                mcChart.Series.Add(ser);




HM Hemalatha Marikumar Syncfusion Team February 25, 2020 12:55 PM UTC

Hi Harsh Shah, 
 
Thanks for your update. 
 
But here, we have a follow-up based on the Syncfusion SfChart control. But your updated code is not related to our control. 
 
Regards, 
Hemalatha M. 


Loader.
Live Chat Icon For mobile
Up arrow icon