<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:namespace="clr-namespace:DHT.Desktop.Dialogs.CheckBox"
        mc:Ignorable="d" d:DesignWidth="500"
        x:Class="DHT.Desktop.Dialogs.CheckBox.CheckBoxDialog"
        Title="{Binding Title}"
        Icon="avares://DiscordHistoryTracker/Resources/icon.ico"
        Width="500" SizeToContent="Height" CanResize="False"
        WindowStartupLocation="CenterOwner">

    <Window.DataContext>
        <namespace:CheckBoxDialogModel />
    </Window.DataContext>

    <Window.Styles>
        <Style Selector="Panel.buttons">
            <Setter Property="Margin" Value="0 20 0 0" />
        </Style>
        <Style Selector="Panel.buttons > WrapPanel.right">
            <Setter Property="HorizontalAlignment" Value="Right" />
        </Style>
        <Style Selector="Panel.buttons Button">
            <Setter Property="MinWidth" Value="80" />
        </Style>
        <Style Selector="Panel.buttons > WrapPanel.left Button">
            <Setter Property="Margin" Value="0 0 8 0" />
        </Style>
        <Style Selector="Panel.buttons > WrapPanel.right Button">
            <Setter Property="Margin" Value="8 0 0 0" />
        </Style>
    </Window.Styles>

    <StackPanel Margin="20">
        <ScrollViewer MaxHeight="400">
            <ItemsControl Items="{Binding Items}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding Checked}">
                            <Label>
                                <TextBlock Text="{Binding Title}" TextWrapping="Wrap" />
                            </Label>
                        </CheckBox>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
        <Panel Classes="buttons">
            <WrapPanel Classes="left">
                <Button Command="{Binding SelectAll}" IsEnabled="{Binding !AreAllSelected}">Select All</Button>
                <Button Command="{Binding SelectNone}" IsEnabled="{Binding !AreNoneSelected}">Select None</Button>
            </WrapPanel>
            <WrapPanel Classes="right">
                <Button Click="ClickOk">OK</Button>
                <Button Click="ClickCancel">Cancel</Button>
            </WrapPanel>
        </Panel>
    </StackPanel>

</Window>
