<UserControl x:Class="Machinations.WPF.UserComponentControlView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="300"
             DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <Style TargetType="ToggleButton" x:Key="UcStyle">
                    <Setter Property="Height" Value ="20"/>
                    <Setter Property="MinWidth" Value="100"></Setter>
                    <Setter Property="MaxWidth" Value="120"></Setter>
                    <Setter Property="Background" Value ="AliceBlue"/>
                    <Setter Property="Margin" Value="1"/>
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                </Style>
                <Style TargetType="ToggleButton" x:Key="NewUcStyle">
                    <Setter Property="Height" Value ="20"/>
                    <Setter Property="MinWidth" Value="100"></Setter>
                    <Setter Property="Background" Value ="Aqua"/>
                    <Setter Property="Margin" Value="1"/>
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                </Style>
                <Style TargetType="TextBlock" > 
                    <Setter Property="Margin" Value="10,0,0,0"/>
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                </Style>
                <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
            </UserControl.Resources>
    <ScrollViewer MaxHeight="200" VerticalScrollBarVisibility="Auto">
        <StackPanel Orientation="Vertical">
            <TextBlock Text="Existing cards :" Visibility="{Binding HasCreatedCards, Converter={StaticResource BoolToVisConverter}}"/>
            <ItemsControl Name="CreatedCardsButtonsControl" ItemsSource="{Binding CreatedCards}" HorizontalAlignment="Center" HorizontalContentAlignment="Stretch" >
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <ToggleButton Content ="{Binding Name}"
                                                ToolTip="{Binding NameDate}"
                                            Style="{StaticResource UcStyle}"
                                            Click="ButtonBase_OnClick"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <Grid>
           <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Vertical">
                <TextBlock Text="New components" HorizontalAlignment="Left" />
                    <ToggleButton  Content="New Component" Click="ButtonBase_OnClick" Tag="UserComponent" Style="{StaticResource NewUcStyle}"/>
                    <ItemsControl Name="UcButtonsControl" ItemsSource="{Binding UserComponents}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <ToggleButton Content ="{Binding Name}"
                                                    ToolTip="{Binding NameDate}"
                                              Style="{StaticResource UcStyle}"
                                              Click="ButtonBase_OnClick"/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>
            <StackPanel Grid.Column="1" Orientation="Vertical" Visibility="{Binding CardsAllowed, Converter={StaticResource BoolToVisConverter}}">
                <TextBlock Text="Cards" HorizontalAlignment="Center"/>
                <ToggleButton  Content="New Card" Click="ButtonBase_OnClick" Tag="Card" Style="{StaticResource NewUcStyle}"/>
                    <ItemsControl Name="CardsButtonsControl" ItemsSource="{Binding Cards}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <ToggleButton Content ="{Binding Name}"
                                                    ToolTip="{Binding NameDate}"
                                              Style="{StaticResource UcStyle}"
                                              Click="ButtonBase_OnClick"
                                                  />
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>
        </Grid>
    </StackPanel>
    </ScrollViewer>
</UserControl>
