<UserControl x:Class="Filtration.Views.ItemFilterScriptView"
             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"
             xmlns:views="clr-namespace:Filtration.Views"
             xmlns:attachedProperties="clr-namespace:Filtration.Views.AttachedProperties"
             xmlns:viewModels="clr-namespace:Filtration.ViewModels"
             xmlns:userControls="clr-namespace:Filtration.UserControls"
             xmlns:utility="clr-namespace:Filtration.Utility"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterScriptViewModel}"
             d:DesignHeight="300" d:DesignWidth="600">
    <UserControl.InputBindings>
        <KeyBinding Command="{Binding CopyBlockCommand}" Modifiers="Control" Key="C" />
        <KeyBinding Command="{Binding PasteBlockCommand}" Modifiers="Control" Key="V" />
        <KeyBinding Command="{Binding CopyBlockStyleCommand}" Modifiers="Shift+Control" Key="C" />
        <KeyBinding Command="{Binding PasteBlockStyleCommand}" Modifiers="Shift+Control" Key="V" />
    </UserControl.InputBindings>
    <!--<utility:RoutedCommandHandlers.Commands>
        <utility:RoutedCommandHandler RoutedCommand="{StaticResource MoveBlockUpRoutedCommand}" Command="{Binding MoveBlockUpCommand}" IsActive="{Binding IsActiveDocument}" />
    </utility:RoutedCommandHandlers.Commands>-->
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <DataTemplate DataType="{x:Type viewModels:ItemFilterBlockViewModel}">
                        <views:ItemFilterBlockView Margin="1" />
                    </DataTemplate>
                    <DataTemplate DataType="{x:Type viewModels:ItemFilterCommentBlockViewModel}">
                        <views:ItemFilterCommentBlockView Margin="1" />
                    </DataTemplate>
                </ResourceDictionary>
                <ResourceDictionary Source="ExpanderStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderThickness="1" BorderBrush="DarkGray"  Margin="5,5,5,0">
            <StackPanel Margin="2,2,2,2">
                <Expander Style="{StaticResource ExpanderRightAlignStyle}">
                    <Expander.Header>
                        <TextBlock Text="Script Description" VerticalAlignment="Center" />
                    </Expander.Header>
                    <Grid>
                        <TextBox Text="{Binding Description, UpdateSourceTrigger=PropertyChanged}" Margin="5" MaxLines="20" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" />
                    </Grid>
                </Expander>
            </StackPanel>
        </Border>
        <Border Grid.Row="1" BorderThickness="1" BorderBrush="DarkGray" Margin="5,5,5,5">
            <DockPanel LastChildFill="True">
                <userControls:AutoScrollingListBox ItemsSource="{Binding ViewItemFilterBlockViewModels}"
                                                   Padding="5"
                                                   HorizontalContentAlignment="Stretch"
                                                   BorderThickness="0"
                                                   ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                                   VirtualizingStackPanel.VirtualizationMode="Recycling"
                                                   attachedProperties:SelectingItemAttachedProperty.SelectingItem="{Binding CommentBlockBrowserBrowserSelectedBlockViewModel}"
                                                   SelectionMode="Extended" attachedProperties:SelectedItemsAttachedProperty.SelectedItems="{Binding SelectedBlockViewModels}">
                    <!--ItemTemplateSelector="{StaticResource BlockTemplateSelector}"-->
                    <ListBox.InputBindings>
                        <KeyBinding Key="Delete" Command="{Binding DeleteBlockCommand}" />
                    </ListBox.InputBindings>
                    <ListBox.Resources>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="ListBoxItem">
                                        <Border Name="Border" Padding="2" SnapsToDevicePixels="true">
                                            <ContentPresenter />
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsSelected" Value="true">
                                                <Setter TargetName="Border" Property="Background" Value="#A9BDD8"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.Resources>
                </userControls:AutoScrollingListBox>
            </DockPanel>
        </Border>
    </Grid>
</UserControl>
