<dragablz:DragablzWindow x:Class="DragablzDemo.BoundExampleWindow"
        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:dragablzDemo="clr-namespace:DragablzDemo"
        xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
        xmlns:dockablz="http://dragablz.net/winfx/xaml/dockablz"
        mc:Ignorable="d"
        Title="Simple form of bound tabs" Height="300" Width="600"        
        d:DataContext="{d:DesignInstance dragablzDemo:BoundExampleModel, IsDesignTimeCreatable=False}">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/Generic.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <DataTemplate DataType="{x:Type dragablz:HeaderedItemViewModel}">
                <ContentControl Content="{Binding Content}" Margin="4 4 4 4" FontSize="14" />
            </DataTemplate>
            <DataTemplate DataType="{x:Type dragablzDemo:CustomHeaderViewModel}">
                <dragablzDemo:CustomHeader />
            </DataTemplate>
            <dragablz:InterTabController x:Key="InterTabController" x:Shared="False" InterTabClient="{Binding InterTabClient}" Partition="2AE89D18-F236-4D20-9605-6C03319038E6" />

            <dragablz:DragablzIcon Width="24" Height="24" Margin="0 -8 0 0"
                                   x:Key="WindowIcon" x:Shared="False"
                                   ToolTip="Added via the HeaderPrefixContent property"
                                   />

            <Style TargetType="{x:Type dragablz:TabablzControl}" x:Key="TabablzControlStyle">
                <Setter Property="NewItemFactory" Value="{x:Static dragablzDemo:BoundExampleNewItem.Factory}" />
                <Setter Property="ItemsSource" Value="{Binding Items}" />
                <Setter Property="ClosingItemCallback" Value="{Binding ClosingTabItemHandler}" />
                <Setter Property="ShowDefaultAddButton" Value="True" />
                <Setter Property="ShowDefaultCloseButton" Value="True" />
                <Setter Property="AdjacentHeaderItemOffset" Value="-10" />
                <Setter Property="ItemContainerStyle" Value="{StaticResource TrapezoidDragableTabItemStyle}" />
                <Setter Property="HeaderMemberPath" Value="Header" />
                <Setter Property="InterTabController" Value="{StaticResource InterTabController}" />
                <Setter Property="Margin" Value="0 8 0 0" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(dockablz:Layout.IsTopLeftItem)}" Value="True">
                        <Setter Property="HeaderPrefixContent" Value="{StaticResource WindowIcon}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Window.Resources>

    <dockablz:Layout Partition="2AE89D18-F236-4D20-9605-6C03319038E6" Name="RootLayout"
                     FloatingItemsSource="{Binding ToolItems}"
                     FloatingItemHeaderMemberPath="Header"
                     IsFloatDropZoneEnabled="True"
                     ClosingFloatingItemCallback="{Binding ClosingFloatingItemHandler}"
                     FloatingItemsContainerMargin="0 2 0 0">
        <!-- branch template lets dragablz create a new tab control after a window is split via docking -->
        <dockablz:Layout.BranchTemplate>
            <DataTemplate>
                <dragablz:TabablzControl Style="{StaticResource TabablzControlStyle}">
                    <dragablz:TabablzControl.InterTabController>
                        <dragablz:InterTabController InterTabClient="{Binding InterTabClient}" Partition="2AE89D18-F236-4D20-9605-6C03319038E6" />
                    </dragablz:TabablzControl.InterTabController>
                </dragablz:TabablzControl>
            </DataTemplate>
        </dockablz:Layout.BranchTemplate>
        <!-- a root, named tab control is needed, so when a tab is torn and a new window is created, the new target tab control can be identified -->
        <dragablz:TabablzControl x:Name="InitialTabablzControl"
                                 FixedHeaderCount="1"
                                 Style="{StaticResource TabablzControlStyle}"
                                 AddLocationHint="After">
            <dragablz:TabablzControl.InterTabController>
                <dragablz:InterTabController InterTabClient="{Binding InterTabClient}" Partition="2AE89D18-F236-4D20-9605-6C03319038E6" />
            </dragablz:TabablzControl.InterTabController>
        </dragablz:TabablzControl>
    </dockablz:Layout>

</dragablz:DragablzWindow>
