<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Dragablz"
    xmlns:dockablz="clr-namespace:Dragablz.Dockablz"
    xmlns:converters="clr-namespace:Dragablz.Converters"
    xmlns:themes="clr-namespace:Dragablz.Themes">

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <converters:EqualityToVisibilityConverter x:Key="EqualityToVisibilityConverter" />
    <converters:BooleanAndToVisibilityConverter x:Key="BooleanAndToVisibilityConverter" />
    <converters:EqualityToBooleanConverter x:Key="EqualityToBooleanConverter" />
    <converters:ShowDefaultCloseButtonConverter x:Key="ShowDefaultCloseButtonConverter" />

    <Style x:Key="FocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type themes:Ripple}">
        <Setter Property="RecognizesAccessKey" Value="True" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="ClipToBounds" Value="{Binding RelativeSource={RelativeSource Self}, Path=(themes:RippleAssist.ClipToBounds)}" />
        <Setter Property="Feedback" Value="{Binding RelativeSource={RelativeSource Self}, Path=Foreground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type themes:Ripple}">
                    <Grid Background="Transparent">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="Normal" To="MousePressed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:1.2" Value="1">
                                                    <EasingDoubleKeyFrame.EasingFunction>
                                                        <SineEase EasingMode="EaseIn" />
                                                    </EasingDoubleKeyFrame.EasingFunction>
                                                </EasingDoubleKeyFrame>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:1.2" Value="1">
                                                    <EasingDoubleKeyFrame.EasingFunction>
                                                        <SineEase EasingMode="EaseIn" />
                                                    </EasingDoubleKeyFrame.EasingFunction>
                                                </EasingDoubleKeyFrame>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.05" Value=".26"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="MousePressed" To="MouseOut">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.12" Value="0">
                                                    <EasingDoubleKeyFrame.EasingFunction>
                                                        <SineEase EasingMode="EaseIn" />
                                                    </EasingDoubleKeyFrame.EasingFunction>
                                                </EasingDoubleKeyFrame>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.12" Value="0">
                                                    <EasingDoubleKeyFrame.EasingFunction>
                                                        <SineEase EasingMode="EaseIn" />
                                                    </EasingDoubleKeyFrame.EasingFunction>
                                                </EasingDoubleKeyFrame>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.12" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition From="MousePressed" To="Normal">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="1" x:Name="MousePressedToNormalScaleXKeyFrame"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.50" Value="1"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.50" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="1" x:Name="MousePressedToNormalScaleYKeyFrame"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.50" Value="1"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.50" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.05" Value=".26"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value=".26"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.50" Value="0">
                                                    <EasingDoubleKeyFrame.EasingFunction>
                                                        <SineEase EasingMode="EaseOut" />
                                                    </EasingDoubleKeyFrame.EasingFunction>
                                                </EasingDoubleKeyFrame>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform" To="0"/>
                                        <DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform" To="0"/>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse" To="0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MousePressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform" To="1"/>
                                        <DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform" To="1"/>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse" To="0.26"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOut">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform" To="0"/>
                                        <DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform" To="0"/>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse" To="0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Canvas IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Ellipse x:Name="ClickEllipse" Fill="{TemplateBinding Feedback}" Opacity="0" 
                                     Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleSize}" 
                                     Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleSize}" 
                                     Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleX}" 
                                     Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleY}"
                                     RenderTransformOrigin=".5,.5">
                                <Ellipse.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform x:Name="ScaleTransform" ScaleX="0" ScaleY="0" />
                                        <SkewTransform/>
                                        <RotateTransform/>
                                        <TranslateTransform x:Name="TranslateTransform"/>
                                    </TransformGroup>
                                </Ellipse.RenderTransform>
                            </Ellipse>
                        </Canvas>
                        <ContentPresenter Content="{TemplateBinding Content}"
                                          ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          RecognizesAccessKey="{TemplateBinding RecognizesAccessKey}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:DragablzIcon}">
        <Setter Property="Width" Value="16" />
        <Setter Property="Height" Value="16" />
        <Setter Property="ToolTip" Value="Dragablz" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzIcon}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Path Data="M7.5937495,21.279167 L52.96875,21.279167 C60.812496,21.279167 67.34375,22.935417 72.5625,26.247917 C78.71875,30.154171 81.796875,35.794796 81.796875,43.169792 C81.796875,48.888542 79.8125,54.935417 75.84375,61.310417 C70.59375,69.716667 62.968746,76.232292 52.96875,80.857292 C43.75,85.107292 33.84375,87.232292 23.25,87.232292 L7.78125,87.232292 L24.75,39.138542 L41.671875,39.138542 L27.28125,79.732292 C33.4375,79.732292 39.539063,77.841667 45.585938,74.060417 C51.632809,70.279167 56.046871,65.607292 58.828125,60.044792 C61.328121,55.138542 62.578121,51.044792 62.578125,47.763542 C62.578121,42.388542 61.078121,38.529167 58.078125,36.185417 C55.390621,34.122921 51.265621,33.091671 45.703125,33.091667 L0.375,33.091667 z" 
                              Fill="{TemplateBinding Foreground}" 
                              Stretch="Uniform" 
                              />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Color x:Key="CloseCommandHighlightColor">#e04343</Color>

    <!-- these tab styles are as close as possible to the default .net styles, so the tab will fit straight in to an unstyled app -->
    <SolidColorBrush x:Key="TabItem.Selected.Background" Color="#FFFFFF"/>
    <SolidColorBrush x:Key="TabItem.Selected.Border" Color="#ACACAC"/>
    <SolidColorBrush x:Key="Button.Static.Background" Color="#FFDDDDDD"/>
    <SolidColorBrush x:Key="Button.Static.Border" Color="#FF707070"/>
    <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
    <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
    <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
    <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
    <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
    <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
    <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>

    <LinearGradientBrush x:Key="TabItem.Static.Background" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#F0F0F0" Offset="0.0"/>
        <GradientStop Color="#E5E5E5" Offset="1.0"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="TabItem.Static.Border" Color="#ACACAC"/>
    <LinearGradientBrush x:Key="TabItem.MouseOver.Background" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#ECF4FC" Offset="0.0"/>
        <GradientStop Color="#DCECFC" Offset="1.0"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="TabItem.MouseOver.Border" Color="#7EB4EA"/>
    <SolidColorBrush x:Key="TabItem.Disabled.Background" Color="#F0F0F0"/>
    <SolidColorBrush x:Key="TabItem.Disabled.Border" Color="#D9D9D9"/>


    <Style TargetType="{x:Type Thumb}" x:Key="InvisibleThumbStyle">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type themes:SystemCommandIcon}">
        <Setter Property="Width" Value="10" />
        <Setter Property="Height" Value="10" />
        <Setter Property="Margin" Value="4 2 4 2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type themes:SystemCommandIcon}">
                    <Path x:Name="Path" 
                          Data="M0.5,71 L70,0.5 M0.5,1 L70,70.5" 
                          Stretch="Uniform"
                          Stroke="{TemplateBinding Foreground}"
                          StrokeThickness="1.5"
                          StrokeStartLineCap="Square" 
                          StrokeEndLineCap="Square"
                          SnapsToDevicePixels="True"                          
                          />
                    <ControlTemplate.Triggers>
                        <Trigger Property="SystemCommandType" Value="MaximizeWindow">
                            <Setter TargetName="Path" Property="Data" Value="M2.5,2.5 L67.5,2.5 L67.5,68 L2.5,68 z" />
                            <Setter TargetName="Path" Property="StrokeThickness" Value="1.25" />
                            <Setter TargetName="Path" Property="RenderOptions.EdgeMode" Value="Aliased" />
                        </Trigger>
                        <Trigger Property="SystemCommandType" Value="MinimzeWindow">
                            <Setter TargetName="Path" Property="Data" Value="M165,40 L234.5,39.5" />
                            <Setter TargetName="Path" Property="StrokeStartLineCap" Value="Flat" />
                            <Setter TargetName="Path" Property="StrokeEndLineCap" Value="Flat" />
                            <Setter TargetName="Path" Property="StrokeThickness" Value="1.25" />
                            <Setter TargetName="Path" Property="RenderOptions.EdgeMode" Value="Aliased" />
                        </Trigger>
                        <Trigger Property="SystemCommandType" Value="RestoreWindow">
                            <Setter TargetName="Path" Property="Data" Value="M2.5,13 L57.576,13 L57.576,69 L2.5,69 z M12.424,2.5 L67.5,2.5 67.5,58.5 57.576,58.5 57.576,13 12.424,13 z" />
                            <Setter TargetName="Path" Property="StrokeThickness" Value="1.25" />
                            <Setter TargetName="Path" Property="RenderOptions.EdgeMode" Value="Aliased" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>

        </Setter>
    </Style>

    <Style TargetType="{x:Type Button}" x:Key="MenuCommandButtonStyle">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Opacity" Value=".8"/>
        <Setter Property="Width" Value="24"/>
        <Setter Property="Height" Value="20"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDefaulted" Value="true">
                            <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
                            <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{x:Static local:DragablzColors.WindowGlassBrush}"/>
                <Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter Property="Opacity" Value="1"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Button}" x:Key="CloseMenuCommandButtonStyle" BasedOn="{StaticResource MenuCommandButtonStyle}">
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="{x:Static SystemColors.ActiveBorderColor}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Width" Value="46" />
        <Setter Property="Margin" Value="0 0 4 0" />
        <Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background">
                    <Setter.Value>
                        <SolidColorBrush Color="{StaticResource CloseCommandHighlightColor}" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Opacity" Value="1"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Button}" x:Key="CloseItemCommandButtonStyle" BasedOn="{StaticResource MenuCommandButtonStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <Ellipse Width="{TemplateBinding Width}"
                                 Height="{TemplateBinding Height}"
                                 Fill="{TemplateBinding Background}"/>
                        <Path x:Name="Path"
                              Data="M0.5,71 L70,0.5 M0.5,1 L70,70.5" 
                              Width="6" Height="6"
                              Stretch="Uniform"
                              Stroke="{TemplateBinding Foreground}"
                              StrokeThickness="1.5"
                              StrokeStartLineCap="Square" 
                              StrokeEndLineCap="Square"
                              SnapsToDevicePixels="True" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="{x:Static SystemColors.ActiveBorderColor}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Width" Value="12" />
        <Setter Property="Height" Value="12" />
        <Setter Property="Margin" Value="4 0 2 0" />
        <Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background">
                    <Setter.Value>
                        <SolidColorBrush Color="{StaticResource CloseCommandHighlightColor}" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Opacity" Value="1"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Button}" x:Key="AddItemCommandButtonStyle" BasedOn="{StaticResource MenuCommandButtonStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <Ellipse Width="{TemplateBinding Width}"
                                 Height="{TemplateBinding Height}"
                                 Fill="{TemplateBinding Background}"/>
                        <Path x:Name="Path"
                              Data="M38,6L38.0003451911513,70.6666666666666 M70.3336667356886,38L5.50002465137562,38" 
                              Width="6" Height="6"
                              Stretch="Uniform"
                              Stroke="{TemplateBinding Foreground}"
                              StrokeThickness="1.5"
                              StrokeStartLineCap="Square" 
                              StrokeEndLineCap="Square"
                              SnapsToDevicePixels="True" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="{x:Static SystemColors.ActiveBorderColor}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Width" Value="12" />
        <Setter Property="Height" Value="12" />
        <Setter Property="Margin" Value="4 0 2 0" />
        <Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{x:Static local:DragablzColors.WindowGlassBrush}"/>
                <Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter Property="Opacity" Value="1"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Button}" x:Key="HideDisabledButtonStyle">
        <Setter Property="Visibility" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(dockablz:Layout.IsFloatingInLayout), Converter={StaticResource BooleanToVisibilityConverter}}" />
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type local:DragablzWindow}">
        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
            <Grid>
                <AdornerDecorator>
                    <Grid>
                        <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                       x:Name="PART_WindowRestoreThumb"/>
                        <ContentPresenter/>
                    </Grid>
                </AdornerDecorator>
                <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="WindowState" Value="Maximized">
                <Setter TargetName="PART_WindowRestoreThumb" Property="IsHitTestVisible" Value="True" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                    <Condition Property="WindowState" Value="Normal"/>
                </MultiTrigger.Conditions>
                <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type local:DragablzWindow}">
        <Setter Property="WindowStyle" Value="None" />
        <Setter Property="AllowsTransparency" Value="True" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
        <Setter Property="Background" Value="{x:Static local:DragablzColors.WindowInactiveBrush}"/>
        <Setter Property="BorderBrush" Value="{x:Static SystemColors.ActiveBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="ResizeMode" Value="CanResize" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzWindow}">
                    <Grid>
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                            <AdornerDecorator>
                                <Grid>
                                    <Grid x:Name="PART_WindowSurface" Background="Transparent" />
                                    <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                           IsHitTestVisible="False"
                                           x:Name="PART_WindowRestoreThumb"/>
                                    <StackPanel x:Name="SystemCommandsPanel" 
                                                HorizontalAlignment="Right"
                                                VerticalAlignment="Top"
                                                Orientation="Horizontal">
                                        <Button Command="{x:Static local:DragablzWindow.MinimizeWindowCommand}"
                                                Style="{StaticResource MenuCommandButtonStyle}">
                                            <themes:SystemCommandIcon SystemCommandType="MinimzeWindow" />
                                        </Button>
                                        <Button Command="{x:Static local:DragablzWindow.RestoreWindowCommand}"
                                                Visibility="{TemplateBinding WindowState, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static WindowState.Maximized}}"
                                                Style="{StaticResource MenuCommandButtonStyle}">
                                            <themes:SystemCommandIcon SystemCommandType="RestoreWindow" />
                                        </Button>
                                        <Button Command="{x:Static local:DragablzWindow.MaximizeWindowCommand}"
                                                Visibility="{TemplateBinding WindowState, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                                Style="{StaticResource MenuCommandButtonStyle}">
                                            <themes:SystemCommandIcon SystemCommandType="MaximizeWindow" />
                                        </Button>
                                        <Button Command="{x:Static local:DragablzWindow.CloseWindowCommand}"
                                                Style="{StaticResource CloseMenuCommandButtonStyle}"
                                                x:Name="CloseWindowCommandButton"
                                                >
                                            <themes:SystemCommandIcon SystemCommandType="CloseWindow" />
                                        </Button>
                                    </StackPanel>
                                    <ContentPresenter Margin="4"/>
                                </Grid>
                            </AdornerDecorator>
                        </Border>
                        <Thumb Style="{StaticResource InvisibleThumbStyle}"
                               x:Name="PART_WindowResizeThumb"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter TargetName="PART_WindowRestoreThumb" Property="IsHitTestVisible" Value="True" />
                        </Trigger>
                        <Trigger Property="IsBeingDraggedByTab" Value="True">
                            <Setter TargetName="SystemCommandsPanel" Property="Visibility" Value="Collapsed"></Setter>
                        </Trigger>
                        <Trigger Property="IsActive" Value="True">
                            <Setter TargetName="CloseWindowCommandButton" Property="Background">
                                <Setter.Value>
                                    <SolidColorBrush Color="{StaticResource CloseCommandHighlightColor}" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
                <Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
            </Trigger>
            <Trigger Property="IsActive" Value="True">
                <Setter Property="Background" Value="{x:Static local:DragablzColors.WindowGlassBalancedBrush}" />
            </Trigger>
            <Trigger Property="IsBeingDraggedByTab" Value="True">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="BorderBrush" Value="Transparent" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type dockablz:DropZone}">
        <Setter Property="Opacity" Value=".25" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type dockablz:DropZone}">
                    <Grid>
                        <Path Fill="{TemplateBinding Foreground}" 
                              Visibility="{TemplateBinding Location, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static dockablz:DropZoneLocation.Top}}"
                              >
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure x:Name="PathFigure" StartPoint="160, 0">
                                        <ArcSegment SweepDirection="Clockwise"
                                                    Size="60,60"
                                                    Point="0, 0"                                                
                                                />
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Fill="{TemplateBinding Foreground}" 
                              Visibility="{TemplateBinding Location, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static dockablz:DropZoneLocation.Right}}"
                              >
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="60, 160">
                                        <ArcSegment SweepDirection="Clockwise"
                                                    Size="60,60"
                                                    Point="60, 0"                                                
                                                    />
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Fill="{TemplateBinding Foreground}" 
                              Visibility="{TemplateBinding Location, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static dockablz:DropZoneLocation.Bottom}}"
                              >
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0, 60">
                                        <ArcSegment SweepDirection="Clockwise"
                                                    Size="60,60"
                                                    Point="160, 60"                                                
                                                    />
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Fill="{TemplateBinding Foreground}" 
                              Visibility="{TemplateBinding Location, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static dockablz:DropZoneLocation.Left}}"
                              >
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0, 0">
                                        <ArcSegment SweepDirection="Clockwise"
                                                    Size="60,60"
                                                    Point="0, 160"                                                
                                                    />
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Ellipse Fill="{TemplateBinding Foreground}"
                                 Visibility="{TemplateBinding Location, Converter={StaticResource EqualityToVisibilityConverter}, ConverterParameter={x:Static dockablz:DropZoneLocation.Floating}}"
                                 Width="120" Height="120"
                                 />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsOffered" Value="True">
                <Setter Property="Opacity" Value="0.5" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:DragablzItemsControl}">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <Canvas IsItemsHost="True" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzItemsControl}">
                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
                                      Width="{TemplateBinding ActualWidth}"
                                      Height="{TemplateBinding ActualHeight}"
                                      Background="{x:Null}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            Width="{TemplateBinding ItemsPresenterWidth}"
                                            Height="{TemplateBinding ItemsPresenterHeight}"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="TabablzScrollViewerControlTemplate" TargetType="{x:Type ScrollViewer}">
        <Grid x:Name="Grid" Background="{TemplateBinding Background}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
            <ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="1" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"
                       Margin="0 1 0 0" />
            <ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="0" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" 
                       Width="36" Height="20"
                       Margin="1 0 0 0" />
        </Grid>
    </ControlTemplate>

    <Style TargetType="{x:Type local:DragablzItemsControl}" x:Key="TabablzDragablzItemsControlStyle">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <Canvas IsItemsHost="True" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzItemsControl}">
                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
                                      Width="{TemplateBinding ActualWidth}"
                                      Height="{TemplateBinding ActualHeight}"
                                      Template="{StaticResource TabablzScrollViewerControlTemplate}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            Width="{TemplateBinding ItemsPresenterWidth}"
                                            Height="{TemplateBinding ItemsPresenterHeight}"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:DragablzItem}">
        <Style.Setters>
            <Setter Property="Canvas.Left" Value="{Binding X, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Canvas.Top" Value="{Binding Y, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:DragablzItem}">
                        <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Thumb Width="30" Height="30" Background="Yellow" x:Name="PART_Thumb" VerticalAlignment="Center" />
                                <ContentPresenter Grid.Column="1" Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
        <Style.Triggers>
            <Trigger Property="IsDragging" Value="True">
                <Setter Property="Opacity" Value=".95" />
            </Trigger>
            <Trigger Property="IsSiblingDragging" Value="True">
                <Setter Property="Opacity" Value=".5" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:HeaderedDragablzItem}">
        <Style.Setters>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Canvas.Left" Value="{Binding X, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Canvas.Top" Value="{Binding Y, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:HeaderedDragablzItem}">
                        <Grid Margin="{TemplateBinding Margin}">
                            <Border Background="White">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="10" ShadowDepth="5" Direction="315" Color="Black" Opacity=".5" />
                                </Border.Effect>
                            </Border>
                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                                <DockPanel>
                                    <Grid DockPanel.Dock="Top" Background="{StaticResource TabItem.Static.Background}">
                                        <ContentPresenter Content="{TemplateBinding HeaderContent}" 
                                                          ContentTemplate="{TemplateBinding HeaderContentTemplate}" 
                                                          ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" 
                                                          ContentTemplateSelector="{TemplateBinding HeaderContentTemplateSelector}"
                                                          VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" 
                                                          SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                                          Margin="{TemplateBinding Control.Padding }"
                                                          />
                                        <Thumb HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb"
                                               Style="{StaticResource InvisibleThumbStyle}"
                                               />
                                    </Grid>
                                    <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                                      Margin="{TemplateBinding Control.Padding }"/>
                                </DockPanel>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>

    <Style TargetType="{x:Type local:HeaderedDragablzItem}" x:Key="ToolDragablzItemStyle">
        <Style.Setters>
            <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}" />
            <Setter Property="BorderThickness" Value="4" />
            <Setter Property="Canvas.Left" Value="{Binding X, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Canvas.Top" Value="{Binding Y, RelativeSource={RelativeSource Self}}" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:HeaderedDragablzItem}">
                        <Grid Margin="{TemplateBinding Margin}">
                            <Border Background="White">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="10" ShadowDepth="5" Direction="315" Color="Black" Opacity=".5" />
                                </Border.Effect>
                            </Border>
                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                                <DockPanel>
                                    <Grid DockPanel.Dock="Top" Background="{StaticResource TabItem.Static.Background}">
                                        <Thumb HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb"
                                               Style="{StaticResource InvisibleThumbStyle}"
                                               />
                                        <DockPanel Margin="{TemplateBinding Control.Padding }">
                                            <Button DockPanel.Dock="Right"
                                                    Command="{x:Static dockablz:Layout.CloseFloatingItem}"
                                                    CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                                    Margin="1 0 0 0"
                                                    Style="{StaticResource HideDisabledButtonStyle}"
                                                    >
                                                <themes:SystemCommandIcon Height="10" Width="10" SystemCommandType="CloseWindow" />
                                            </Button>
                                            <Button DockPanel.Dock="Right"
                                                    Command="{x:Static dockablz:Layout.UnfloatItemCommand}"
                                                    CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                                    Margin="1 0 0 0"
                                                    Style="{StaticResource HideDisabledButtonStyle}"
                                                    >
                                                <Path Width="12" Height="12" Stretch="UniformToFill" Fill="#000000" Data="M 19 19 H 5 V 5 h 7 V 3 H 5 C 3.89 3 3 3.9 3 5 v 14 c 0 1.1 0.89 2 2 2 h 14 c 1.1 0 2 -0.9 2 -2 v -7 h -2 v 7 z M 14 3 v 2 h 3.59 L 7.76 14.83 9.17 16.24 19 6.41 V 10 h 2 V 3 h -7 z" />
                                            </Button>
                                            <Button DockPanel.Dock="Right"
                                                    Command="{x:Static dockablz:Layout.MaximiseFloatingItem}"
                                                    CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                                    Margin="1 0 0 0"
                                                    Style="{StaticResource HideDisabledButtonStyle}"
                                                    >
                                                <themes:SystemCommandIcon Height="10" Width="10" SystemCommandType="MaximizeWindow" />
                                            </Button>
                                            <Button DockPanel.Dock="Right"
                                                    Command="{x:Static dockablz:Layout.RestoreFloatingItem}"
                                                    CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                                    Margin="1 0 0 0"
                                                    Style="{StaticResource HideDisabledButtonStyle}"
                                                    >
                                                <themes:SystemCommandIcon Height="10" Width="10" SystemCommandType="RestoreWindow" />
                                            </Button>
                                            <ContentPresenter Content="{TemplateBinding HeaderContent}"                                                               
                                                              ContentTemplate="{TemplateBinding HeaderContentTemplate}" 
                                                              ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" 
                                                              ContentTemplateSelector="{TemplateBinding HeaderContentTemplateSelector}"                                                          
                                                              SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"                                                              
                                                              IsHitTestVisible="False"
                                                          />
                                        </DockPanel>
                                    </Grid>
                                    <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                                      Margin="{TemplateBinding Control.Padding }"                                                      
                                                      />
                                </DockPanel>
                            </Border>
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Left}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="Left"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Stretch"
                                   Cursor="SizeWE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Top}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="Top"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Top"
                                   Cursor="SizeNS"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="Right"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Stretch"
                                   Cursor="SizeWE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="Bottom"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNS"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="TopLeft"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   Cursor="SizeNWSE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="TopRight"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Top"
                                   Cursor="SizeNESW"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="BottomRight"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNWSE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   IsEnabled="{Binding Path=(dockablz:Layout.FloatingItemState), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource EqualityToBooleanConverter}, ConverterParameter={x:Static WindowState.Normal}}"
                                   local:DragablzItem.SizeGrip="BottomLeft"                                   
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNESW"
                                   />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
        <Style.Triggers>
            <Trigger Property="dockablz:Layout.FloatingItemState" Value="Maximized">
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="Canvas.Left" Value="0" />
                <Setter Property="Canvas.Top" Value="0" />
                <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dockablz:Layout}}, Path=ActualWidth}" />
                <Setter Property="Height" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dockablz:Layout}}, Path=ActualHeight}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:DragablzItem}" x:Key="SizableFromBottomRightDragablzItemStyle">
        <Style.Setters>
            <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}" />
            <Setter Property="BorderThickness" Value="4" />
            <Setter Property="Canvas.Left" Value="{Binding X, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Canvas.Top" Value="{Binding Y, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:DragablzItem}">
                        <Grid Margin="{TemplateBinding Margin}">
                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                                <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                                  Margin="{TemplateBinding Control.Padding }"/>
                            </Border>
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   local:DragablzItem.SizeGrip="BottomRight"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNWSE"
                                   />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>

    <Style TargetType="{x:Type local:DragablzItem}" x:Key="FloatingDragablzItemStyle">
        <Style.Setters>
            <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}" />
            <Setter Property="BorderThickness" Value="4" />
            <Setter Property="Canvas.Left" Value="{Binding X, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Canvas.Top" Value="{Binding Y, RelativeSource={RelativeSource Self}}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:DragablzItem}">
                        <Grid Margin="{TemplateBinding Margin}">
                            <Border Background="White">
                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="10" ShadowDepth="5" Direction="315" Color="Black" Opacity=".5" />
                                </Border.Effect>
                            </Border>
                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                                <Grid Cursor="ScrollAll">
                                    <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                                      Margin="{TemplateBinding Control.Padding }"/>
                                    <Thumb HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb"
                                           Style="{StaticResource InvisibleThumbStyle}"
                                           />
                                </Grid>
                            </Border>
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Left}"
                                   local:DragablzItem.SizeGrip="Left"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Stretch"
                                   Cursor="SizeWE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Top}"
                                   local:DragablzItem.SizeGrip="Top"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Top"
                                   Cursor="SizeNS"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   local:DragablzItem.SizeGrip="Right"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Stretch"
                                   Cursor="SizeWE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   local:DragablzItem.SizeGrip="Bottom"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNS"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   local:DragablzItem.SizeGrip="TopLeft"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   Cursor="SizeNWSE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   local:DragablzItem.SizeGrip="TopRight"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Top"
                                   Cursor="SizeNESW"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   local:DragablzItem.SizeGrip="BottomRight"
                                   HorizontalAlignment="Right"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNWSE"
                                   />
                            <Thumb Style="{StaticResource InvisibleThumbStyle}"
                                   Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Right}"
                                   Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Bottom}"
                                   local:DragablzItem.SizeGrip="BottomLeft"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Bottom"
                                   Cursor="SizeNESW"
                                   />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>

    <Style x:Key="StandardEmbeddedButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1 -2 1 -2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDefaulted" Value="true">
                            <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
                            <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TrapezoidDragableTabItemStyle"  TargetType="{x:Type local:DragablzItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
        <Setter Property="Margin" Value="0 0 0 0"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="true" Margin="0 1 0 -1">
                        <local:Trapezoid x:Name="Trapezoid" 
                                         BorderBrush="{TemplateBinding BorderBrush}" 
                                         Background="{TemplateBinding Background}"                                          
                                         PenThickness="2"
                                         Margin="0 0 0 0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                                  Margin="{TemplateBinding Control.Padding}"
                                                  x:Name="contentPresenter" />
                                <Thumb Grid.Column="0" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" 
                                       x:Name="PART_Thumb"
                                       Style="{StaticResource InvisibleThumbStyle}" />
                                <Button Grid.Column="1"
                                        Style="{StaticResource CloseItemCommandButtonStyle}"                                        
                                        Command="{x:Static local:TabablzControl.CloseItemCommand}"
                                        CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                    <Button.Visibility>
                                        <MultiBinding Converter="{StaticResource ShowDefaultCloseButtonConverter}">
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:TabablzControl}}" Path="ShowDefaultCloseButton" />
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:TabablzControl}}" Path="FixedHeaderCount" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="LogicalIndex" />
                                        </MultiBinding>
                                    </Button.Visibility>
                                </Button>
                            </Grid>
                        </local:Trapezoid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="local:TabablzControl.IsWrappingTabItem" Value="True">
                            <Setter TargetName="contentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Header}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Background" Value="{StaticResource TabItem.Selected.Background}" TargetName="Trapezoid"/>
                            <Setter Property="LongBasePenBrush" Value="{StaticResource TabItem.Selected.Background}" TargetName="Trapezoid"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- this style is effectively a duplicate of CoreTabItemStyle, allowing users to bind tabs in and immedietly get a standard tab look -->
    <Style x:Key="StandardDragablzTabItemStyle" TargetType="{x:Type local:DragablzItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="6,2,6,2"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
                        <Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Margin="0 0 0 1">
                            <Border x:Name="innerBorder" BorderBrush="{StaticResource TabItem.Selected.Border}" BorderThickness="1,1,1,0" Background="{StaticResource TabItem.Selected.Background}" Margin="-1" Opacity="0"/>
                        </Border>
                        <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                          x:Name="contentPresenter"
                                          Margin="{TemplateBinding Control.Padding}" />
                        <Thumb HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb"
                               Style="{StaticResource InvisibleThumbStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="local:TabablzControl.IsWrappingTabItem" Value="True">
                            <Setter TargetName="contentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Header}" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="-2,-2,0,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="-2,0,-2,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="0,-2,-2,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}"                                            
                                           Value="True"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="0,0,0,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="StandardDragablzTabItemVerticalStyle" TargetType="{x:Type local:DragablzItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="6,2,6,2"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
                        <Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,1" Background="{TemplateBinding Background}">
                            <Border x:Name="innerBorder" BorderBrush="{StaticResource TabItem.Selected.Border}" BorderThickness="1,1,0,1" Background="{StaticResource TabItem.Selected.Background}" Margin="-1" Opacity="0"/>
                        </Border>
                        <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                          x:Name="contentPresenter"
                                          Margin="{TemplateBinding Control.Padding}" />
                        <Thumb HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb"
                               Style="{StaticResource InvisibleThumbStyle}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="local:TabablzControl.IsWrappingTabItem" Value="True">
                            <Setter TargetName="contentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Header}" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <!--
                            <Setter Property="Margin" Value="-2,-2,-2,0"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <!--
                            <Setter Property="Margin" Value="0,-2,-2,-2"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="0,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <!--
                            <Setter Property="Margin" Value="-2,0,-2,-2"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,0,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,0,1,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                            -->
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}"                                            
                                           Value="True"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="0,0,-2,0"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <!--
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,0,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,0,1"/>
                            -->
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="{x:Type local:TabablzControl}">
        <Setter Property="Padding" Value="2"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="{StaticResource TabItem.Selected.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItem.Selected.Border}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource StandardDragablzTabItemStyle}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TabablzControl}">
                    <Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                            <RowDefinition x:Name="RowDefinition1" Height="*"/>
                        </Grid.RowDefinitions>
                        <Border x:Name="contentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local"
                                Margin="0 -1 0 0">
                            <Grid x:Name="PART_ItemsHolder" />
                        </Border>
                        <Grid Grid.Column="0" Grid.Row="0" Margin="0,2,2,0" x:Name="HeaderContainerGrid" Visibility="{TemplateBinding IsHeaderPanelVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <Grid.Resources>
                                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource StandardEmbeddedButtonStyle}"></Style>
                            </Grid.Resources>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <ContentControl Grid.Column="0" x:Name="PrefixContentControl" 
                                            Content="{TemplateBinding HeaderPrefixContent}"
                                            ContentStringFormat="{TemplateBinding HeaderPrefixContentStringFormat}"
                                            ContentTemplate="{TemplateBinding HeaderPrefixContentStringFormat}"
                                            ContentTemplateSelector="{TemplateBinding HeaderPrefixContentTemplateSelector}"/>
                            <local:DragablzItemsControl x:Name="PART_HeaderItemsControl"                                                         
                                                        Grid.Column="1"
                                                        ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}"                                                                                                            
                                                        ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                                        ItemsOrganiser="{TemplateBinding HeaderItemsOrganiser}"
                                                        KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"
                                                        ItemTemplate="{TemplateBinding HeaderItemTemplate}"
                                                        FixedItemCount="{TemplateBinding FixedHeaderCount}"
                                                        Style="{StaticResource TabablzDragablzItemsControlStyle}">
                                <local:DragablzItemsControl.MaxWidth>
                                    <MultiBinding>
                                        <MultiBinding.Converter>
                                            <local:TabablzHeaderSizeConverter Orientation="Horizontal"/>
                                        </MultiBinding.Converter>
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ActualWidth" />
                                        <Binding RelativeSource="{RelativeSource Self}" Path="ItemsPresenterWidth" />
                                        <Binding ElementName="PrefixContentControl" Path="ActualWidth" />
                                        <Binding ElementName="DefaultAddButton" Path="DesiredSize.Width" />
                                        <Binding ElementName="SuffixContentControl" Path="DesiredSize.Width" />
                                    </MultiBinding>
                                </local:DragablzItemsControl.MaxWidth>
                            </local:DragablzItemsControl>
                            <Button Style="{StaticResource AddItemCommandButtonStyle}"
                                    x:Name="DefaultAddButton"
                                    Grid.Column="2"
                                    Command="{x:Static local:TabablzControl.AddItemCommand}"
                                    Visibility="{TemplateBinding ShowDefaultAddButton, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    />
                            <ContentControl Grid.Column="3" x:Name="SuffixContentControl" 
                                            Content="{TemplateBinding HeaderSuffixContent}"
                                            ContentStringFormat="{TemplateBinding HeaderSuffixContentStringFormat}"
                                            ContentTemplate="{TemplateBinding HeaderSuffixContentStringFormat}"
                                            ContentTemplateSelector="{TemplateBinding HeaderSuffixContentTemplateSelector}"                                            
                                            HorizontalAlignment="Stretch"
                                            />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHeaderPanelVisible" Value="False">
                            <Setter Property="Margin" TargetName="contentPanel" Value="0 0 0 0"/>
                        </Trigger> 
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="PART_HeaderItemsControl" Value="1"/>
                            <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                            <Setter Property="Margin" TargetName="PART_HeaderItemsControl" Value="2,0,2,2"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="PART_HeaderItemsControl" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="PART_HeaderItemsControl" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="PART_HeaderItemsControl" Value="2,2,0,2"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="PART_HeaderItemsControl" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="PART_HeaderItemsControl" Value="1"/>
                            <Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="PART_HeaderItemsControl" Value="0,2,2,2"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                        <Trigger Property="IsDraggingWindow" Value="True">
                            <Setter TargetName="DefaultAddButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="TabStripPlacement" Value="Left">
                <Setter Property="HeaderItemsOrganiser">
                    <Setter.Value>
                        <local:VerticalOrganiser />
                    </Setter.Value>
                </Setter>
                <Setter Property="ItemContainerStyle" Value="{StaticResource StandardDragablzTabItemVerticalStyle}"></Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:TabablzControl}">
                            <Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="ColumnDefinition0" Width="Auto"/>
                                    <ColumnDefinition x:Name="ColumnDefinition1" Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Border x:Name="contentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="1" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local" Margin="-1 0 0 0">
                                    <Grid x:Name="PART_ItemsHolder" />
                                </Border>
                                <Grid Grid.Column="0" x:Name="HeaderContainerGrid" Visibility="{TemplateBinding IsHeaderPanelVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <ContentControl Grid.Row="0" x:Name="PrefixContentControl" 
                                                    Content="{TemplateBinding HeaderPrefixContent}"
                                                    ContentStringFormat="{TemplateBinding HeaderPrefixContentStringFormat}"
                                                    ContentTemplate="{TemplateBinding HeaderPrefixContentStringFormat}"
                                                    ContentTemplateSelector="{TemplateBinding HeaderPrefixContentTemplateSelector}"/>
                                    <local:DragablzItemsControl x:Name="PART_HeaderItemsControl"                                                         
                                                                Grid.Row="1"
                                                                ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}"                                                                                                            
                                                                ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                                                ItemsOrganiser="{TemplateBinding HeaderItemsOrganiser}"
                                                                KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"
                                                                ItemTemplate="{TemplateBinding HeaderItemTemplate}"
                                                                Style="{StaticResource TabablzDragablzItemsControlStyle}">
                                        <local:DragablzItemsControl.MaxHeight>
                                            <MultiBinding>
                                                <MultiBinding.Converter>
                                                    <local:TabablzHeaderSizeConverter Orientation="Vertical"/>
                                                </MultiBinding.Converter>
                                                <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ActualHeight" />
                                                <Binding RelativeSource="{RelativeSource Self}" Path="ItemsPresenterHeight" />
                                                <Binding ElementName="PrefixContentControl" Path="ActualHeight" />
                                                <Binding ElementName="DefaultAddButton" Path="DesiredSize.Height" />
                                                <Binding ElementName="SuffixContentControl" Path="DesiredSize.Height" />
                                            </MultiBinding>
                                        </local:DragablzItemsControl.MaxHeight>
                                    </local:DragablzItemsControl>
                                    <Button Style="{StaticResource AddItemCommandButtonStyle}"
                                            x:Name="DefaultAddButton"
                                            Grid.Row="2"
                                            Command="{x:Static local:TabablzControl.AddItemCommand}"
                                            Visibility="{TemplateBinding ShowDefaultAddButton, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                    <ContentControl Grid.Row="3" x:Name="SuffixContentControl" 
                                                    Content="{TemplateBinding HeaderSuffixContent}"
                                                    ContentStringFormat="{TemplateBinding HeaderSuffixContentStringFormat}"
                                                    ContentTemplate="{TemplateBinding HeaderSuffixContentStringFormat}"
                                                    ContentTemplateSelector="{TemplateBinding HeaderSuffixContentTemplateSelector}"
                                                    VerticalAlignment="Top" />
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:Trapezoid}">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Padding" Value="2 2 2 2" />
        <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}" />
        <Setter Property="PenBrush" Value="{StaticResource TabItem.Static.Border}" />
        <Setter Property="PenThickness" Value=".5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Trapezoid}">
                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:DragablzItemsControl}" x:Key="FloatingDragablzItemsControlStyle">
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="ItemsOrganiser">
            <Setter.Value>
                <local:CanvasOrganiser />
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <Canvas IsItemsHost="True" ClipToBounds="True" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DragablzItemsControl}">
                    <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Top"
                                        Width="{TemplateBinding ItemsPresenterWidth}"
                                        Height="{TemplateBinding ItemsPresenterHeight}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="dockablz:Layout">
        <Setter Property="FloatingItemsControlStyle" Value="{StaticResource FloatingDragablzItemsControlStyle}" />
        <!--Setter Property="FloatingItemContainerStyle" Value="{StaticResource FloatingDragablzItemStyle}" /-->
        <Setter Property="FloatingItemContainerStyleSelector">
            <Setter.Value>
                <dockablz:CouldBeHeaderedStyleSelector NonHeaderedStyle="{StaticResource FloatingDragablzItemStyle}"
                                                       HeaderedStyle="{StaticResource ToolDragablzItemStyle}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dockablz:Layout">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" />
                            <ContentPresenter x:Name="PART_FloatContentPresenter" Margin="{TemplateBinding FloatingItemsContainerMargin}" />
                            <dockablz:DropZone x:Name="PART_TopDropZone" 
                                               VerticalAlignment="Top" HorizontalAlignment="Center"                                               
                                               Location="Top"                                               
                                               Visibility="{TemplateBinding IsParticipatingInDrag, Converter={StaticResource BooleanToVisibilityConverter}}"
                                               />
                            <dockablz:DropZone x:Name="PART_RightDropZone" 
                                               VerticalAlignment="Center" HorizontalAlignment="Right"
                                               Location="Right"                                               
                                               Visibility="{TemplateBinding IsParticipatingInDrag, Converter={StaticResource BooleanToVisibilityConverter}}"
                                               />
                            <dockablz:DropZone x:Name="PART_BottomDropZone" 
                                               VerticalAlignment="Bottom" HorizontalAlignment="Center"
                                               Location="Bottom"                                               
                                               Visibility="{TemplateBinding IsParticipatingInDrag, Converter={StaticResource BooleanToVisibilityConverter}}"
                                               />
                            <dockablz:DropZone x:Name="PART_LeftDropZone" 
                                               VerticalAlignment="Center" HorizontalAlignment="Left"
                                               Location="Left"                                               
                                               Visibility="{TemplateBinding IsParticipatingInDrag, Converter={StaticResource BooleanToVisibilityConverter}}"
                                               />
                            <dockablz:DropZone x:Name="PART_FloatDropZone" 
                                               VerticalAlignment="Center" HorizontalAlignment="Center"
                                               Location="Floating">
                                <dockablz:DropZone.Visibility>
                                    <MultiBinding Converter="{StaticResource BooleanAndToVisibilityConverter}">
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="IsParticipatingInDrag" />
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="IsFloatDropZoneEnabled" />
                                    </MultiBinding>
                                </dockablz:DropZone.Visibility>
                            </dockablz:DropZone>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type dockablz:Branch}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type dockablz:Branch}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FirstItemLength, Mode=TwoWay}" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SecondItemLength, Mode=TwoWay}" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter x:Name="PART_FirstContentPresenter" Content="{TemplateBinding FirstItem}" />
                            <GridSplitter Grid.Column="1" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" 
                                          Width="5"/>
                            <ContentPresenter x:Name="PART_SecondContentPresenter" Grid.Column="2" Content="{TemplateBinding SecondItem}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type dockablz:Branch}">
                            <Border Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=FirstItemLength, Mode=TwoWay}" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SecondItemLength, Mode=TwoWay}" />
                                    </Grid.RowDefinitions>
                                    <ContentPresenter x:Name="PART_FirstContentPresenter" Content="{TemplateBinding FirstItem}" />
                                    <GridSplitter Grid.Row="1" ResizeDirection="Rows" ResizeBehavior="PreviousAndNext" Height="5" HorizontalAlignment="Stretch" />
                                    <ContentPresenter x:Name="PART_SecondContentPresenter" Grid.Row="2" Content="{TemplateBinding SecondItem}" />
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary> 
 
 
 
