<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
                    xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                    xmlns:behaviours="clr-namespace:ArkBot.Browser.Behaviours"
                    xmlns:controls="clr-namespace:ArkBot.Controls"
                    xmlns:configuration="clr-namespace:ArkBot.Configuration">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/CollectionControl/Themes/Generic.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <configuration:TypeToDisplayNameConverter x:Key="TypeToDisplayNameConverter" />
    <Style TargetType="xctk:CollectionControlDialog">
        <Setter Property="UseLayoutRounding" Value="True" />
        <Style.Resources>
            <Style TargetType="xctk:CollectionControl">
                <Style.Resources>
                    <Style TargetType="ListBox">
                        <Setter Property="ItemTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Converter={StaticResource ObjectTypeToNameConverter}}" />
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Style.Resources>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type xctk:CollectionControl}">
                            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid Margin="{TemplateBinding Padding}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="300" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition />
                                        </Grid.RowDefinitions>
                                        <TextBlock Margin="0,0,0,5" Text="Select type:" />
                                        <ComboBox x:Name="PART_NewItemTypesComboBox" Grid.Row="1" Margin="0,0,0,3" HorizontalAlignment="Stretch">
                                            <ComboBox.ItemsSource>
                                                <MultiBinding Converter="{StaticResource NewItemTypesComboBoxConverter}">
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ItemsSourceType" />
                                                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="NewItemTypes" />
                                                </MultiBinding>
                                            </ComboBox.ItemsSource>
                                            <ComboBox.ItemTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Converter={StaticResource TypeToDisplayNameConverter}}"/>
                                                </DataTemplate>
                                            </ComboBox.ItemTemplate>
                                        </ComboBox>
                                        <Button Margin="3,0,0,3" Grid.Row="1" Grid.Column="1" Padding="5,0" Content="Add" Command="New" CommandParameter="{Binding SelectedItem, ElementName=PART_NewItemTypesComboBox}" />
                                        <ListBox x:Name="PART_ListBox" Grid.Row="2" Grid.ColumnSpan="2" ItemsSource="{Binding Items, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" SelectedIndex="0">
                                        </ListBox>
                                        <StackPanel Margin="7,2,0,0" VerticalAlignment="Top" Grid.Column="2" Grid.Row="2">
                                            <Button Style="{StaticResource CollectionControlButtonStyle}" Command="ComponentCommands.MoveUp" CommandParameter="{Binding SelectedItem, ElementName=PART_ListBox}">
                                                <Path Fill="#FF404040" Data="F0 M 6,0 L 12,7 8,7 8,12 4,12 4,7 0,7 Z" />
                                            </Button>
                                            <Button Margin="0,1,0,0" Style="{StaticResource CollectionControlButtonStyle}" Command="ComponentCommands.MoveDown" CommandParameter="{Binding SelectedItem, ElementName=PART_ListBox}">
                                                <Path Fill="#FF404040" Data="F0 M 4,0 L 8,0 8,5 12,5 6,12 0,5 4,5 Z" />
                                            </Button>
                                            <Button Margin="0,7,0,0" Style="{StaticResource CollectionControlButtonStyle}" Command="Delete" CommandParameter="{Binding SelectedItem, ElementName=PART_ListBox}">
                                                <Image Stretch="None" Height="16" Width="16" Margin="1" Source="/Xceed.Wpf.Toolkit;component/CollectionControl/Images/Delete16.png" />
                                            </Button>
                                        </StackPanel>
                                    </Grid>
                                    <Grid Column="1" Margin="20,0,0,0">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition />
                                        </Grid.RowDefinitions>
                                        <TextBlock Grid.Column="1" Text="Properties:" />
                                        <controls:Configuration Grid.Row="1" Grid.Column="1" Margin="0,5,0,0" Model="{Binding DataContext, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type xctk:CollectionControlDialog}}}" SelectedObject="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" />
                                    </Grid>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" TargetName="PART_NewItemTypesComboBox" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.Resources>
    </Style>
</ResourceDictionary>
