<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:InABox.DynamicGrid"
    xmlns:wpf="clr-namespace:InABox.WPF"
    xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
    xmlns:themes="clr-namespace:InABox.WPF.Themes"
    x:Class="InABox.WPF.Generic"
    x:ClassModifier="public">
    
    <wpf:ObjectToVisibilityConverter x:Key="DynamicTabControlVisibilityConverter" IsNull="Collapsed" NotNull="Visible" />

    <!-- VerticalSplitter -->
    <ControlTemplate x:Key="VerticalSplitter">
        <Grid Background="{TemplateBinding Background}" Width="4">
            <Button x:Name="PART_Left" Visibility="Collapsed" />
            <Button x:Name="PART_Right" Visibility="Collapsed" />
            <StackPanel Margin="0" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="0,2,0,0" />
            </StackPanel>
        </Grid>
    </ControlTemplate>

    <!-- HorizontalSplitter -->
    <ControlTemplate x:Key="HorizontalSplitter">
        <Grid Background="{TemplateBinding Background}" Height="4">
            <Button x:Name="PART_Left" Visibility="Collapsed" />
            <Button x:Name="PART_Right" Visibility="Collapsed" />
            <StackPanel Margin="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
                <Ellipse Fill="Silver" HorizontalAlignment="Center" Height="2" Width="2" Opacity="1" Margin="2,0,0,0" />
            </StackPanel>
        </Grid>
    </ControlTemplate>

    <Style TargetType="wpf:ZoomPanel">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="wpf:ZoomPanel">
                    <ControlTemplate.Resources>
                        <wpf:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <ScrollViewer Grid.Row="0"
                                      Background="{TemplateBinding Background}"
                                      x:Name="PART_Scroll"
                                      HorizontalScrollBarVisibility="Auto"
                                      VerticalScrollBarVisibility="Auto">
                            <Border Background="Transparent" x:Name="PART_ContentBorder">
                                <ContentControl x:Name="PART_ZoomContent" VerticalAlignment="Center" Content="{TemplateBinding Content}" HorizontalAlignment="Center">
                                    <ContentControl.LayoutTransform>
                                        <ScaleTransform ScaleX="{Binding Scale,RelativeSource={RelativeSource TemplatedParent}}"
                                                        ScaleY="{Binding Scale,RelativeSource={RelativeSource TemplatedParent}}"/>
                                    </ContentControl.LayoutTransform>
                                </ContentControl>
                            </Border>
                        </ScrollViewer>
                        <DockPanel Grid.Row="1" LastChildFill="False"
                                   Visibility="{Binding ShowNavigationButtons,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource BoolToVisibilityConverter}}">
                            <Button x:Name="PART_ZoomInButton" Margin="5">
                                <Image Source="pack://application:,,,/InABox.Wpf;component/Resources/zoomin.png" Width="32" Height="32"/>
                            </Button>
                            <Button x:Name="PART_ZoomOutButton" Margin="0,5,5,5">
                                <Image Source="pack://application:,,,/InABox.Wpf;component/Resources/zoomout.png" Width="32" Height="32"/>
                            </Button>
                            <Button x:Name="PART_LeftButton" Margin="0,5,5,5">
                                <Image Source="pack://application:,,,/InABox.Wpf;component/Resources/leftarrow.png" Width="32" Height="32"/>
                            </Button>
                            <Button x:Name="PART_RightButton" Margin="0,5,5,5">
                                <Image Source="pack://application:,,,/InABox.Wpf;component/Resources/rightarrow.png" Width="32" Height="32"/>
                            </Button>
                            <Button x:Name="PART_UpButton" Margin="0,5,5,5">
                                <Image Source="pack://application:,,,/InABox.Wpf;component/Resources/uparrow.png" Width="32" Height="32"/>
                            </Button>
                            <Button x:Name="PART_DownButton" Margin="0,5,5,5">
                                <Image Source="pack://application:,,,/InABox.Wpf;component/Resources/downarrow.png" Width="32" Height="32"/>
                            </Button>
                        </DockPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- DynamicSplitPanel -->
    <Style TargetType="{x:Type local:DynamicSplitPanel}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DynamicSplitPanel}">
                    <Grid x:Name="PART_Grid">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="0" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <!-- Collapsed Master -->
                        <DockPanel Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Margin="0,0,4,0">

                            <Button 
                                DockPanel.Dock="Top" 
                                x:Name="PART_DetailsOnly" 
                                BorderBrush="Gray"
                                BorderThickness="0.75" 
                                Margin="0,0,0,4" 
                                Background="WhiteSmoke" 
                                MinHeight="25"
                                MinWidth="25"
                                Focusable="False"  
                                HorizontalAlignment="Stretch"
                                Height="{Binding ElementName=PART_CombinedRight, Path=ActualHeight}">
                                <Polygon 
                                    Points="1,0 9,5, 1,10" 
                                    Stroke="Gray" 
                                    Fill="Silver" />
                            </Button>

                            <Border 
                                DockPanel.Dock="Top" 
                                BorderBrush="Gray" 
                                BorderThickness="0.75" 
                                Background="WhiteSmoke" 
                                HorizontalAlignment="Stretch">
                                <Label 
                                    x:Name="PART_MasterHeader"
                                    Content="{Binding MasterCaption, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}"
                                    HorizontalContentAlignment="Right">
                                    <Label.LayoutTransform>
                                        <RotateTransform Angle="270" />
                                    </Label.LayoutTransform>
                                </Label>
                            </Border>
                        </DockPanel>

                        <!-- Master Header -->
                        <DockPanel Grid.Row="0" Grid.Column="1">

                            <Button x:Name="PART_CombinedRight" BorderBrush="Gray" BorderThickness="0.75"
                                    Margin="4,0,0,4" Background="WhiteSmoke" DockPanel.Dock="Right" MinWidth="25"
                                    MinHeight="25" HorizontalContentAlignment="Center"
                                    VerticalContentAlignment="Center" Focusable="False">
                                <Polygon Points="1,0 9,5, 1,10" Stroke="Gray" Fill="Silver" />
                            </Button>

                            <Button x:Name="PART_CombinedLeft" BorderBrush="Gray" BorderThickness="0.75"
                                    Margin="4,0,0,4" Background="WhiteSmoke" DockPanel.Dock="Right" MinWidth="25"
                                    MinHeight="25" Focusable="False">
                                <Polygon Points="9,0 1,5, 9,10" Stroke="Gray" Fill="Silver" />
                            </Button>

                            <ContentPresenter DockPanel.Dock="Left" MinHeight="25" Margin="0,0,0,4"
                                              Content="{Binding Header, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}" />

                        </DockPanel>

                        <!-- Master -->
                        <ContentPresenter Grid.Row="1" Grid.Column="1"
                                          Content="{Binding Master, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}" />

                        <syncfusion:SfGridSplitter Grid.Row="0" Grid.RowSpan="2" Grid.Column="2" Name="PART_Splitter"
                                                   ResizeBehavior="PreviousAndNext" Width="4" Background="Transparent"
                                                   Template="{StaticResource VerticalSplitter}">

                            <syncfusion:SfGridSplitter.PreviewStyle>
                                <Style TargetType="Control">
                                    <Setter Property="Background" Value="Gray" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="Control">
                                                <Grid x:Name="Root" Opacity="0.5">
                                                    <Rectangle Fill="{TemplateBinding Background}" />
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </syncfusion:SfGridSplitter.PreviewStyle>

                        </syncfusion:SfGridSplitter>

                        <!-- Detail Header -->
                        <ContentPresenter Grid.Row="0" Grid.Column="3" Margin="0,0,0,4"
                                          Content="{Binding DetailHeader, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}" />

                        <!-- Detail -->
                        <Grid x:Name="PART_DetailGrid" Grid.Row="1" Grid.Column="3">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <ContentPresenter Grid.Row="0"
                                              Content="{Binding Detail, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}" />

                            <syncfusion:SfGridSplitter Grid.Row="1" Name="PART_DetailSplitter"
                                                       ResizeBehavior="PreviousAndNext" Height="4"
                                                       HorizontalAlignment="Stretch" Background="Transparent"
                                                       Template="{StaticResource HorizontalSplitter}">

                                <syncfusion:SfGridSplitter.PreviewStyle>
                                    <Style TargetType="Control">
                                        <Setter Property="Background" Value="Gray" />
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Control">
                                                    <Grid x:Name="Root" Opacity="0.5">
                                                        <Rectangle Fill="{TemplateBinding Background}" />
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </syncfusion:SfGridSplitter.PreviewStyle>

                            </syncfusion:SfGridSplitter>

                            <ContentPresenter Grid.Row="2"
                                              Content="{Binding SecondaryDetail, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}" />

                        </Grid>

                        <!-- Collapsed Detail -->
                        <DockPanel Grid.Row="0" Grid.Column="4" Grid.RowSpan="2" Margin="4,0,0,0">

                            <Button 
                                DockPanel.Dock="Top" 
                                x:Name="PART_MasterOnly" 
                                BorderBrush="Gray"
                                BorderThickness="0.75" 
                                Margin="0,0,0,4" 
                                Background="WhiteSmoke" 
                                MinHeight="25"
                                MinWidth="25"
                                Focusable="False"
                                Height="{Binding ElementName=PART_CombinedRight, Path=ActualHeight}">
                                <Polygon 
                                    Points="9,0 1,5, 9,10" 
                                    Stroke="Gray" 
                                    Fill="Silver" />
                            </Button>

                            <Border 
                                DockPanel.Dock="Top" 
                                BorderBrush="Gray" 
                                BorderThickness="0.75" 
                                Background="WhiteSmoke">
                                <Label 
                                    x:Name="PART_DetailHeader"
                                    Content="{Binding DetailCaption, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicSplitPanel}}"
                                    HorizontalContentAlignment="Right">
                                    <Label.LayoutTransform>
                                        <RotateTransform Angle="270" />
                                    </Label.LayoutTransform>
                                </Label>
                            </Border>
                        </DockPanel>

                    </Grid>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="syncfusion:GridFilterControl">
        <Setter Property="SortOptionVisibility" Value="Collapsed" />
    </Style>

    <!-- VerticalColumnHeader -->
    <Style x:Key="ActionColumnHeader" TargetType="{x:Type syncfusion:GridHeaderCellControl}">
        <Setter Property="Background" Value="LightSkyBlue" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="BorderThickness" Value="0.5,0.5,0.5,0.5" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Padding" Value="5,3" />
        <Setter Property="FontFamily" Value="Segoe UI" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type syncfusion:GridHeaderCellControl}">
                    <Grid>
                        <Grid.LayoutTransform>
                            <RotateTransform Angle="90" />
                        </Grid.LayoutTransform>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="HiddenColumnsResizingStates">
                                <VisualState x:Name="PreviousColumnHidden">
                                    <Storyboard>
                                        <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                                          Storyboard.TargetProperty="BorderThickness"
                                                                          Storyboard.TargetName="PART_HeaderCellBorder">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="3,0,1,1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="HiddenState">
                                    <Storyboard>
                                        <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                                          Storyboard.TargetProperty="BorderThickness"
                                                                          Storyboard.TargetName="PART_HeaderCellBorder">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="3,0,3,1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="NormalState" />
                                <VisualState x:Name="LastColumnHidden">
                                    <Storyboard>
                                        <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                                          Storyboard.TargetProperty="BorderThickness"
                                                                          Storyboard.TargetName="PART_HeaderCellBorder">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="0,0,3,1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Normal" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="BorderStates">
                                <VisualState x:Name="NormalCell" />
                                <VisualState x:Name="FooterColumnCell">
                                    <Storyboard BeginTime="0">
                                        <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                                          Storyboard.TargetProperty="BorderThickness"
                                                                          Storyboard.TargetName="PART_FooterCellBorder">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="1,0,1,1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="BeforeFooterColumnCell">
                                    <Storyboard BeginTime="0">
                                        <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                                          Storyboard.TargetProperty="BorderThickness"
                                                                          Storyboard.TargetName="PART_FooterCellBorder">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="0,0,0,1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                        <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                                          Storyboard.TargetProperty="BorderThickness"
                                                                          Storyboard.TargetName="PART_HeaderCellBorder">
                                            <EasingThicknessKeyFrame KeyTime="0" Value="0,0,0,1" />
                                        </ThicknessAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="PART_FooterCellBorder" BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}" />
                        <Border x:Name="PART_HeaderCellBorder" BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                            <Grid Margin="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Content="{TemplateBinding Content}"
                                                  ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                  Focusable="False"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="Center" />
                                <Grid x:Name="PART_SortButtonPresenter" Grid.Column="1" SnapsToDevicePixels="True">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*">
                                            <ColumnDefinition.MinWidth>
                                                <Binding Mode="OneWay" Path="SortDirection"
                                                         RelativeSource="{RelativeSource TemplatedParent}">
                                                    <Binding.Converter>
                                                        <syncfusion:SortDirectionToWidthConverter />
                                                    </Binding.Converter>
                                                </Binding>
                                            </ColumnDefinition.MinWidth>
                                        </ColumnDefinition>
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Path
                                        Data="F1M753.644,-13.0589L753.736,-12.9639 753.557,-12.7816 732.137,8.63641 732.137,29.7119 756.445,5.40851 764.094,-2.24384 764.275,-2.42352 771.834,5.1286 796.137,29.4372 796.137,8.36163 774.722,-13.0589 764.181,-23.5967 753.644,-13.0589z"
                                        Fill="Gray" HorizontalAlignment="Center" Height="8.138" Stretch="Fill"
                                        SnapsToDevicePixels="True" VerticalAlignment="Center" Width="8.938">
                                        <Path.RenderTransform>
                                            <TransformGroup>
                                                <RotateTransform Angle="90" />
                                                <ScaleTransform ScaleY="1" ScaleX="1" />
                                            </TransformGroup>
                                        </Path.RenderTransform>
                                        <!-- <Path.Visibility> -->
                                        <!--     <Binding ConverterParameter="Ascending" Path="SortDirection" RelativeSource="{RelativeSource TemplatedParent}"> -->
                                        <!--         <Binding.Converter> -->
                                        <!--             <syncfusion:SortDirectionToVisibilityConverter/> -->
                                        <!--         </Binding.Converter> -->
                                        <!--     </Binding> -->
                                        <!-- </Path.Visibility> -->
                                    </Path>
                                    <Path
                                        Data="F1M181.297,177.841L181.205,177.746 181.385,177.563 202.804,156.146 202.804,135.07 178.497,159.373 170.847,167.026 170.666,167.205 163.107,159.653 138.804,135.345 138.804,156.42 160.219,177.841 170.76,188.379 181.297,177.841z"
                                        Fill="Gray" HorizontalAlignment="Center" Height="8.138" Stretch="Fill"
                                        SnapsToDevicePixels="True" VerticalAlignment="Center" Width="8.938">
                                        <Path.RenderTransform>
                                            <TransformGroup>
                                                <RotateTransform Angle="90" />
                                                <ScaleTransform ScaleY="1" ScaleX="1" />
                                            </TransformGroup>
                                        </Path.RenderTransform>
                                        <!-- <Path.Visibility> -->
                                        <!--     <Binding ConverterParameter="Decending" Path="SortDirection" RelativeSource="{RelativeSource TemplatedParent}"> -->
                                        <!--         <Binding.Converter> -->
                                        <!--             <syncfusion:SortDirectionToVisibilityConverter/> -->
                                        <!--         </Binding.Converter> -->
                                        <!--     </Binding> -->
                                        <!-- </Path.Visibility> -->
                                    </Path>
                                    <TextBlock Grid.Column="1" Foreground="{TemplateBinding Foreground}" FontSize="10"
                                               Margin="0,-4,0,0" SnapsToDevicePixels="True"
                                               Text="{TemplateBinding SortNumber}"
                                               Visibility="{TemplateBinding SortNumberVisibility}"
                                               VerticalAlignment="Center" />
                                </Grid>
                                <syncfusion:FilterToggleButton x:Name="PART_FilterToggleButton" Grid.Column="2"
                                                               HorizontalAlignment="Stretch" SnapsToDevicePixels="True"
                                                               Visibility="{TemplateBinding FilterIconVisiblity}"
                                                               VerticalAlignment="Stretch" />
                                <Border x:Name="PART_FilterPopUpPresenter" />
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="VerticalColumnHeader"
         TargetType="{x:Type syncfusion:GridHeaderCellControl}">
        <Grid>
            <Grid.LayoutTransform>
                <RotateTransform Angle="270" />
            </Grid.LayoutTransform>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="HiddenColumnsResizingStates">
                    <VisualState x:Name="PreviousColumnHidden">
                        <Storyboard>
                            <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                              Storyboard.TargetProperty="BorderThickness"
                                                              Storyboard.TargetName="PART_HeaderCellBorder">
                                <EasingThicknessKeyFrame KeyTime="0" Value="3,0,1,1" />
                            </ThicknessAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="HiddenState">
                        <Storyboard>
                            <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                              Storyboard.TargetProperty="BorderThickness"
                                                              Storyboard.TargetName="PART_HeaderCellBorder">
                                <EasingThicknessKeyFrame KeyTime="0" Value="3,0,3,1" />
                            </ThicknessAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="NormalState" />
                    <VisualState x:Name="LastColumnHidden">
                        <Storyboard>
                            <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                              Storyboard.TargetProperty="BorderThickness"
                                                              Storyboard.TargetName="PART_HeaderCellBorder">
                                <EasingThicknessKeyFrame KeyTime="0" Value="0,0,3,1" />
                            </ThicknessAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="MouseOver" />
                    <VisualState x:Name="Normal" />
                </VisualStateGroup>
                <VisualStateGroup x:Name="BorderStates">
                    <VisualState x:Name="NormalCell" />
                    <VisualState x:Name="FooterColumnCell">
                        <Storyboard BeginTime="0">
                            <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                              Storyboard.TargetProperty="BorderThickness"
                                                              Storyboard.TargetName="PART_FooterCellBorder">
                                <EasingThicknessKeyFrame KeyTime="0" Value="1,0,1,1" />
                            </ThicknessAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="BeforeFooterColumnCell">
                        <Storyboard BeginTime="0">
                            <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                              Storyboard.TargetProperty="BorderThickness"
                                                              Storyboard.TargetName="PART_FooterCellBorder">
                                <EasingThicknessKeyFrame KeyTime="0" Value="0,0,0,1" />
                            </ThicknessAnimationUsingKeyFrames>
                            <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1.0:0:0"
                                                              Storyboard.TargetProperty="BorderThickness"
                                                              Storyboard.TargetName="PART_HeaderCellBorder">
                                <EasingThicknessKeyFrame KeyTime="0" Value="0,0,0,1" />
                            </ThicknessAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="PART_FooterCellBorder" BorderBrush="{TemplateBinding BorderBrush}"
                    Background="{TemplateBinding Background}" />
            <Border x:Name="PART_HeaderCellBorder" BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                <Grid Margin="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <ContentPresenter
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        Content="{TemplateBinding Content}">
                    </ContentPresenter>
                    <Grid x:Name="PART_SortButtonPresenter" Grid.Column="1" SnapsToDevicePixels="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*">
                                <ColumnDefinition.MinWidth>
                                    <Binding Mode="OneWay" Path="SortDirection"
                                             RelativeSource="{RelativeSource TemplatedParent}">
                                        <Binding.Converter>
                                            <syncfusion:SortDirectionToWidthConverter />
                                        </Binding.Converter>
                                    </Binding>
                                </ColumnDefinition.MinWidth>
                            </ColumnDefinition>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="1" Foreground="{TemplateBinding Foreground}"
                                   FontSize="10" Margin="0,-4,0,0" SnapsToDevicePixels="True"
                                   Text="{TemplateBinding SortNumber}"
                                   Visibility="{TemplateBinding SortNumberVisibility}"
                                   VerticalAlignment="Bottom" />
                    </Grid>
                    <syncfusion:FilterToggleButton x:Name="PART_FilterToggleButton" Grid.Column="2"
                                                   HorizontalAlignment="Stretch"
                                                   SnapsToDevicePixels="True"
                                                   Visibility="{TemplateBinding FilterIconVisiblity}"
                                                   VerticalAlignment="Stretch">
                        <syncfusion:FilterToggleButton.LayoutTransform>
                            <RotateTransform Angle="90" />
                        </syncfusion:FilterToggleButton.LayoutTransform>
                    </syncfusion:FilterToggleButton>
                    <Border x:Name="PART_FilterPopUpPresenter">
                        <Border.LayoutTransform>
                            <RotateTransform Angle="90" />
                        </Border.LayoutTransform>
                    </Border>
                </Grid>
            </Border>
        </Grid>
    </ControlTemplate>
    
    
    <Style BasedOn="{StaticResource {x:Type TabItem}}" TargetType="{x:Type local:DynamicTabItem}">

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DynamicTabItem}">
                    <Border Name="Panel" BorderBrush="Gray" PreviewMouseRightButtonUp="Panel_OnPreviewMouseRightButtonUp">
                        <Border.MinHeight>
                            <MultiBinding>
                                <MultiBinding.Converter>
                                    <wpf:DoubleCalculator Type="Sum" Constants="-0.75" />
                                </MultiBinding.Converter>
                                <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:DynamicTabControl}}" Path="TabStripHeight" />
                            </MultiBinding>
                        </Border.MinHeight>
                        <DockPanel>
                            <Button x:Name="CloseButton" DockPanel.Dock="Right" Content="x" BorderThickness="0"
                                    Padding="5,0,5,0" Background="Transparent" VerticalContentAlignment="Center"
                                    HorizontalContentAlignment="Center"
                                    IsEnabled="True" Margin="2"
                                    Command="{TemplateBinding CloseTabCommand}" />
                            <ContentPresenter
                                x:Name="ContentSite"
                                DockPanel.Dock="Left"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                ContentSource="Header"
                                Margin="10,0"
                                />
                        </DockPanel>
                    </Border>

                    <ControlTemplate.Triggers>

                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Panel" Property="Background"
                                    Value="{Binding Path=(themes:ThemeManager.SelectedTabItemBackgroundBrush)}" />
                            <Setter TargetName="Panel" Property="TextBlock.Foreground"
                                    Value="{Binding Path=(themes:ThemeManager.SelectedTabItemForegroundBrush)}" />
                        </Trigger>

                        <Trigger Property="IsSelected" Value="False">
                            <Setter TargetName="Panel" Property="Background"
                                    Value="{Binding Path=(themes:ThemeManager.WorkspaceBackgroundBrush)}" />
                            <Setter TargetName="Panel" Property="TextBlock.Foreground"
                                    Value="{Binding Path=(themes:ThemeManager.WorkspaceForegroundBrush)}" />
                        </Trigger>

                        <Trigger Property="CanClose" Value="True">
                            <Setter TargetName="CloseButton" Property="Visibility" Value="Visible" />
                        </Trigger>

                        <Trigger Property="CanClose" Value="False">
                            <Setter TargetName="CloseButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Top}">
                            <Setter TargetName="Panel" Property="CornerRadius" Value="5,5,0,0" />
                            <Setter TargetName="Panel" Property="Margin" Value="0,0,2,0" />
                            <Setter TargetName="Panel" Property="BorderThickness" Value="0.75,0.75,0.75,0" />
                        </Trigger>

                        <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Bottom}">
                            <Setter TargetName="Panel" Property="CornerRadius" Value="0,0,5,5" />
                            <Setter TargetName="Panel" Property="Margin" Value="0,0,2,0" />
                            <Setter TargetName="Panel" Property="BorderThickness" Value="0.75,0,0.75,0.75" />
                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

    <!-- ~1~ This template explains how to render a tab item with a close button. @1@ -->
    <!-- <DataTemplate x:Key="ClosableTabItemHeader"> -->
    <!--     <DockPanel MinWidth="120"> -->
    <!--         <Button DockPanel.Dock="Right" Command="ApplicationCommands.Delete" CommandParameter="{Binding}" Content="X" Cursor="Hand" Focusable="False" FontSize="10" FontWeight="Bold" Height="16" Width="16" /> -->
    <!--         <TextBlock Padding="0,0,10,0" Text="{Binding DisplayName}" VerticalAlignment="Center" /> -->
    <!--     </DockPanel> -->
    <!-- </DataTemplate> -->

    <!-- ~1~ This template explains how to render a tab item with a new button. @1@ -->
    <!-- <DataTemplate x:Key="NewTabItemHeader"> -->
    <!--     <Button Command="{Binding NewTabCommand, RelativeSource={RelativeSource AncestorType={x:Type local:DynamicTabControl}}}" Content="+" Cursor="Hand" Focusable="False" FontWeight="Bold" -->
    <!--             Width="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/> -->
    <!-- </DataTemplate> -->

    <Style BasedOn="{StaticResource {x:Type TabControl}}" TargetType="{x:Type local:DynamicTabControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DynamicTabControl}">
                    <Grid Background="{Binding Path=(themes:ThemeManager.WorkspaceBackgroundBrush)}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="2" x:Name="TopSeparator"/>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="0" x:Name="BottomSeparator" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        
                        <Border 
                            x:Name="Separator" 
                            BorderBrush="Gray"
                            Grid.Column="0"
                            Grid.ColumnSpan="5"
                            Padding="0"
                            MinHeight="{Binding TabStripHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicTabControl}}">
                            <DockPanel x:Name="Panel" Background="{Binding Path=(themes:ThemeManager.WorkspaceBackgroundBrush)}"  Margin="0">
                                <Button x:Name="AddButton" DockPanel.Dock="Right" Content="+"
                                        BorderThickness="0" Padding="5,0,5,0" Background="Transparent"
                                        Command="{TemplateBinding CreateTabCommand}" />
                                <TabPanel IsItemsHost="true" Background="Transparent" VerticalAlignment="Stretch" Margin="0"/>
                            </DockPanel>
                        </Border>
                        
                        <!-- Margin="0,2,0,2" -->
                        <ContentPresenter 
                            Grid.Row="2"
                            Grid.Column="0"
                            ContentSource="LeftPanel" />
 
                        <syncfusion:SfGridSplitter 
                            Grid.Row="2" 
                            Grid.Column="1" 
                            ResizeBehavior="PreviousAndNext" 
                            Width="4" 
                            Background="Transparent"
                            Visibility="{Binding LeftPanel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicTabControl}, Converter={StaticResource DynamicTabControlVisibilityConverter}}"
                            Template="{StaticResource VerticalSplitter}"/>                        
                        
                        <ContentPresenter
                            Grid.Row="2"
                            Grid.Column="2"
                            x:Name="PART_SelectedContentHost"
                            ContentSource="SelectedContent" 
                            />

                        
                        <syncfusion:SfGridSplitter 
                            Grid.Row="2" 
                            Grid.Column="3" 
                            ResizeBehavior="PreviousAndNext" 
                            Width="4" 
                            Background="Transparent"
                            Visibility="{Binding RightPanel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicTabControl}, Converter={StaticResource DynamicTabControlVisibilityConverter}}"
                            Template="{StaticResource VerticalSplitter}"/>                        

                        
                        <!-- Margin="0,2,0,2" -->
                        <ContentPresenter 
                            Grid.Row="2"
                            Grid.Column="4"
                            ContentSource="RightPanel" />
                        
                    </Grid>
                    
                    <ControlTemplate.Triggers>

                        <Trigger Property="CanCreateTab" Value="True">
                            <Setter TargetName="AddButton" Property="Visibility" Value="Visible" />
                        </Trigger>

                        <Trigger Property="CanCreateTab" Value="False">
                            <Setter TargetName="AddButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>

                        <!-- <Trigger Property="TabStripPlacement" Value="{x:Static Dock.Top}"> -->
                        <!--     <Setter TargetName="Panel" Property="Grid.Row" Value="0" /> -->
                        <!--     <Setter TargetName="Content" Property="BorderThickness" Value="0,0.75,0,0" /> -->
                        <!--     <Setter TargetName="Content" Property="Padding" Value="0,2,0,0" /> -->
                        <!-- </Trigger> -->
                        
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TabStripPlacement" Value="{x:Static Dock.Top}" />
                                <Condition Property="TabStripVisible" Value="False"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Separator" Property="Grid.Row" Value="0" />
                                <Setter TargetName="Separator" Property="BorderThickness" Value="0,0,0,0" />
                                <Setter TargetName="TopSeparator" Property="Height" Value="0" />
                                <Setter TargetName="BottomSeparator" Property="Height" Value="0" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TabStripPlacement" Value="{x:Static Dock.Top}" />
                                <Condition Property="TabStripVisible" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Separator" Property="Grid.Row" Value="0" />
                                <Setter TargetName="Separator" Property="BorderThickness" Value="0,0,0,0.75" />                                
                                <Setter TargetName="Separator" Property="Margin" Value="0,0,0,0" />
                                <Setter TargetName="TopSeparator" Property="Height" Value="{Binding SeparatorMargin, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicTabControl}}" />
                                <Setter TargetName="BottomSeparator" Property="Height" Value="0" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TabStripPlacement" Value="{x:Static Dock.Bottom}" />
                                <Condition Property="TabStripVisible" Value="False"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Separator" Property="Grid.Row" Value="4" />
                                <Setter TargetName="Separator" Property="BorderThickness" Value="0,0,0,0" />
                                <Setter TargetName="TopSeparator" Property="Height" Value="0" />
                                <Setter TargetName="BottomSeparator" Property="Height" Value="0" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TabStripPlacement" Value="{x:Static Dock.Bottom}" />
                                <Condition Property="TabStripVisible" Value="True"/>
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="Separator" Property="Grid.Row" Value="4" />
                                <Setter TargetName="Separator" Property="BorderThickness" Value="0,0.75,0,0" />
                                <Setter TargetName="Separator" Property="Margin" Value="0,0,0,0" />
                                <Setter TargetName="TopSeparator" Property="Height" Value="0" />
                                <Setter TargetName="BottomSeparator" Property="Height" Value="{Binding SeparatorMargin, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DynamicTabControl}}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

</ResourceDictionary>