<Page
    x:Class="UWP.CartesianChart.DynamicVisibility.DynamicVisibilityExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UWP.CartesianChart.DynamicVisibility"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:lvc="using:LiveCharts.Uwp"
    xmlns:converters="using:UWP.Converters"
    xmlns:lvcConverters="using:LiveCharts.Uwp.Converters"
    mc:Ignorable="d">
    <UserControl.Resources>
        <converters:BoolToObjectConverter x:Key="bvc">
            <converters:BoolToObjectConverter.TrueValue>
                <x:Boolean>True</x:Boolean>
            </converters:BoolToObjectConverter.TrueValue>
            <converters:BoolToObjectConverter.FalseValue>
                <x:Boolean>False</x:Boolean>
            </converters:BoolToObjectConverter.FalseValue>
        </converters:BoolToObjectConverter>
    </UserControl.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding MariaSeriesVisibility, Mode=TwoWay}">
                    Maria Series
                </CheckBox>
            <CheckBox IsChecked="{Binding CharlesSeriesVisibility, Mode=TwoWay}">
                    Charles Series
                </CheckBox>
            <CheckBox IsChecked="{Binding JohnSeriesVisibility, Mode=TwoWay}">
                    John Series
                </CheckBox>
            </StackPanel>
        <lvc:CartesianChart Grid.Row="1" Hoverable="False">
            <lvc:CartesianChart.Series>
                <lvc:ColumnSeries Title="Maria" Values="{Binding MariaValues}" Visibility="{Binding MariaSeriesVisibility, Converter={StaticResource bvc}, Mode=OneWay}" MaxWidth="1000" ColumnPadding="0"/>
                <lvc:ColumnSeries Title="Charles" Values="{Binding CharlesValues}" Visibility="{Binding CharlesSeriesVisibility, Converter={StaticResource bvc}, Mode=OneWay}" MaxWidth="1000" ColumnPadding="0"/>
                <lvc:ColumnSeries Title="John" Values="{Binding JohnValues}" Visibility="{Binding JohnSeriesVisibility, Converter={StaticResource bvc}, Mode=OneWay}" MaxWidth="1000" ColumnPadding="0"/>
            </lvc:CartesianChart.Series>
            <lvc:CartesianChart.AxisX>
                <lvc:Axis Labels="{Binding Labels}">
                    <lvc:Axis.Separator>
                        <lvc:Separator Step="1"/>
                    </lvc:Axis.Separator>
                </lvc:Axis>
            </lvc:CartesianChart.AxisX>
        </lvc:CartesianChart>
    </Grid>
</Page>
