<UserControl
    x:Class="Sonex.Client.Controls.CheckListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sonex.Client.Controls">
    <UserControl.Resources>
        <Style TargetType="CheckBox"
           BasedOn="{StaticResource DefaultToggleButtonStyle}">
            <Setter Property="Padding" Value="12 6 6 6" />
            <Setter Property="Margin" Value="6,6,12,6" />
            <Setter Property="Foreground" Value="{ThemeResource TextFillColorPrimaryBrush}" />
        </Style>
    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto">
        <ItemsControl ItemsSource="{x:Bind ItemsSource, Mode=OneWay}"
                      HorizontalAlignment="Stretch">
            <ItemsControl.ItemTemplate>
                <DataTemplate x:DataType="local:CheckListItem">
                    <CheckBox IsChecked="{x:Bind Checked, Mode=TwoWay}"
                              Tag="{Binding}"
                              HorizontalAlignment="Stretch"
                              HorizontalContentAlignment="Stretch"
                              Click="CheckBox_Click">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <FontIcon Grid.Column="0"
                                      Glyph="{x:Bind IconGlyph}"
                                      Visibility="{x:Bind IconVisibility}"
                                      Margin="0,0,10,0"
                                      FontSize="12"
                                      Opacity="0.8"
                                      VerticalAlignment="Center" />

                            <StackPanel Grid.Column="1" Spacing="2">
                                <TextBlock Text="{x:Bind DisplayTitle}"
                                           FontSize="14"
                                           FontWeight="SemiBold" />

                                <TextBlock Text="{x:Bind Description}"
                                           Visibility="{x:Bind DescriptionVisibility}"
                                           TextWrapping="Wrap" />

                                <TextBlock Text="{x:Bind KeyValueText}"
                                           Visibility="{x:Bind KeyValueVisibility}"
                                           FontSize="12" />
                            </StackPanel>
                        </Grid>
                    </CheckBox>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </ScrollViewer>
</UserControl>
