<UserControl x:Class="Showcase.WPF.DragDrop.Views.TreeViewSamples"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dd="urn:gong-wpf-dragdrop"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:viewModels="clr-namespace:Showcase.WPF.DragDrop.ViewModels"
             d:DataContext="{d:DesignInstance viewModels:MainViewModel}"
             d:DesignHeight="400"
             d:DesignWidth="600"
             mc:Ignorable="d">

    <Grid>
        <Grid.Resources>
            <Style BasedOn="{StaticResource DefaultTreeViewStyle}" TargetType="{x:Type TreeView}" />
        </Grid.Resources>

        <TabControl Style="{StaticResource ShowcaseTabControlStyle}">
            <TabItem Header="Bound">
                <TabItem.Resources>
                    <Style x:Key="BoundTreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                        <Setter Property="Padding" Value="2" />
                    </Style>
                </TabItem.Resources>
                <DockPanel LastChildFill="True">
                    <TextBlock DockPanel.Dock="Top"
                               Style="{StaticResource SampleHeaderTextBlockStyle}"
                               Text="TreeView Unbound" />
                    <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                        <StackPanel>
                            <TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two TreeViews bound to two collections of the same type. Just try drag and drop some Items from left TreeView to right TreeView." />
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TreeView x:Name="LeftBoundTreeView"
                                          Grid.Column="0"
                                          dd:DragDrop.IsDragSource="True"
                                          dd:DragDrop.IsDropTarget="True"
                                          dd:DragDrop.UseDefaultDragAdorner="True"
                                          dd:DragDrop.UseDefaultEffectDataTemplate="True"
                                          dd:DragDrop.SelectDroppedItems="True"
                                          ItemContainerStyle="{StaticResource BoundTreeViewItemStyle}"
                                          Loaded="LeftBoundTreeView_Loaded"
                                          ItemsSource="{Binding Data.TreeCollection1}">
                                    <TreeView.ItemTemplate>
                                        <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                            <TextBlock Margin="2" Text="{Binding Caption}" />
                                        </HierarchicalDataTemplate>
                                    </TreeView.ItemTemplate>
                                </TreeView>
                                <TreeView Grid.Column="1"
                                          dd:DragDrop.IsDragSource="True"
                                          dd:DragDrop.IsDropTarget="True"
                                          dd:DragDrop.UseDefaultDragAdorner="True"
                                          ItemContainerStyle="{StaticResource BoundTreeViewItemStyle}"
                                          ItemsSource="{Binding Data.TreeCollection2}">
                                    <TreeView.ItemTemplate>
                                        <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                                            <TextBlock Margin="2" Text="{Binding Caption}" />
                                        </HierarchicalDataTemplate>
                                    </TreeView.ItemTemplate>
                                </TreeView>
                            </Grid>

                            <TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left TreeView)" />
                            <CheckBox Margin="10 5"
                                      Content="IsDragSource"
                                      IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="10 5"
                                      Content="IsDropTarget"
                                      IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="10 5"
                                      Content="UseDefaultDragAdorner"
                                      IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="10 5"
                                      Content="UseDefaultEffectDataTemplate"
                                      IsChecked="{Binding ElementName=LeftBoundTreeView, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        </StackPanel>
                    </ScrollViewer>
                </DockPanel>
            </TabItem>

            <TabItem Header="Unbound">
                <DockPanel LastChildFill="True">
                    <TextBlock DockPanel.Dock="Top"
                               Style="{StaticResource SampleHeaderTextBlockStyle}"
                               Text="TreeView Unbound" />
                    <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                        <StackPanel>
                            <TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Demonstrates the default behaviour with two TreeViews and unbound items (e.g. direct usage of TreeViewItem). Just try drag and drop some Items from left TreeView to right TreeView." />
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TreeView x:Name="LeftUnboundTreeView"
                                          Grid.Column="0"
                                          dd:DragDrop.IsDragSource="True"
                                          dd:DragDrop.IsDropTarget="True"
                                          dd:DragDrop.UseDefaultDragAdorner="True"
                                          dd:DragDrop.UseDefaultEffectDataTemplate="True">
                                    <TreeViewItem Header="Root 1" IsExpanded="True">
                                        <TreeViewItem Header="Item 10" />
                                        <TreeViewItem Header="Item 20" />
                                        <TreeViewItem Header="Item 30" />
                                        <TreeViewItem Header="Item 40" />
                                        <TreeViewItem Header="Item 50" />
                                    </TreeViewItem>
                                    <TreeViewItem Header="Root 2" IsExpanded="True">
                                        <TreeViewItem Header="Item 20" />
                                        <TreeViewItem Header="Item 21" />
                                        <TreeViewItem Header="Item 22" />
                                    </TreeViewItem>
                                    <TreeViewItem Header="Root 3" />
                                </TreeView>
                                <TreeView Grid.Column="1"
                                          dd:DragDrop.IsDragSource="True"
                                          dd:DragDrop.IsDropTarget="True"
                                          dd:DragDrop.UseDefaultDragAdorner="True" />
                            </Grid>

                            <TextBlock Style="{StaticResource DefaultTextBlockStyle}" Text="Customization (for left TreeView)" />
                            <CheckBox Margin="10 5"
                                      Content="IsDragSource"
                                      IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.IsDragSource), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="10 5"
                                      Content="IsDropTarget"
                                      IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.IsDropTarget), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="10 5"
                                      Content="UseDefaultDragAdorner"
                                      IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.UseDefaultDragAdorner), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="10 5"
                                      Content="UseDefaultEffectDataTemplate"
                                      IsChecked="{Binding ElementName=LeftUnboundTreeView, Path=(dd:DragDrop.UseDefaultEffectDataTemplate), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        </StackPanel>
                    </ScrollViewer>
                </DockPanel>
            </TabItem>
        </TabControl>

    </Grid>

</UserControl>