<ResourceDictionary
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:CompileBindings="True">
    <!--  Add Resources Here  -->
    <ControlTheme x:Key="{x:Type TabControl}" TargetType="TabControl">
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Background" Value="{DynamicResource TabControlBackground}" />
        <Setter Property="Template">
            <ControlTemplate TargetType="TabControl">
                <Border
                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalAlignment}"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}">
                    <DockPanel>
                        <Panel DockPanel.Dock="{TemplateBinding TabStripPlacement}">
                            <ItemsPresenter Name="PART_ItemsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" />
                            <Border Name="PART_BorderSeparator" Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
                        </Panel>
                        <ContentPresenter
                            Name="PART_SelectedContentHost"
                            Margin="{TemplateBinding Padding}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            Content="{TemplateBinding SelectedContent}"
                            ContentTemplate="{TemplateBinding SelectedContentTemplate}" />
                    </DockPanel>
                </Border>
            </ControlTemplate>
        </Setter>

        <Style Selector="^[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter &gt; WrapPanel">
            <Setter Property="Orientation" Value="Vertical" />
        </Style>
        <Style Selector="^[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter &gt; WrapPanel">
            <Setter Property="Orientation" Value="Vertical" />
        </Style>
        <Style Selector="^[TabStripPlacement=Left] /template/ Border#PART_BorderSeparator">
            <Setter Property="Width" Value="1" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>
        <Style Selector="^[TabStripPlacement=Right] /template/ Border#PART_BorderSeparator">
            <Setter Property="Width" Value="1" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="HorizontalAlignment" Value="Right" />
        </Style>
        <Style Selector="^[TabStripPlacement=Top] /template/ Border#PART_BorderSeparator">
            <Setter Property="Height" Value="1" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
        </Style>
        <Style Selector="^[TabStripPlacement=Bottom] /template/ Border#PART_BorderSeparator">
            <Setter Property="Height" Value="1" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Top" />
        </Style>
        <!--
        <Style Selector="^[TabStripPlacement=Top] /template/ ItemsPresenter#PART_ItemsPresenter">
            <Setter Property="Margin" Value="8" />
        </Style>
        -->
    </ControlTheme>
    
    <ControlTheme x:Key="ScrollTabControl" TargetType="TabControl">
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Background" Value="{DynamicResource TabControlBackground}" />
        <Setter Property="ItemsPanel">
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </Setter>
        <Setter Property="Template">
            <ControlTemplate TargetType="TabControl">
                <Border
                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalAlignment}"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}">
                    <DockPanel>
                        <Panel DockPanel.Dock="{TemplateBinding TabStripPlacement}">
                            <ScrollViewer Name="PART_ScrollViewer">
                                <ItemsPresenter Name="PART_ItemsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" Margin="0 0 12 12"/>
                            </ScrollViewer>
                            <Border Name="PART_BorderSeparator" Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
                        </Panel>
                        <ContentPresenter
                            Name="PART_SelectedContentHost"
                            Margin="{TemplateBinding Padding}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            Content="{TemplateBinding SelectedContent}"
                            ContentTemplate="{TemplateBinding SelectedContentTemplate}" />
                    </DockPanel>
                </Border>
            </ControlTemplate>
        </Setter>
        
        <Style Selector="^[TabStripPlacement=Left], ^[TabStripPlacement=Right]">
            <Style Selector="^ /template/ ItemsPresenter">
                <Setter Property="ItemsPanel">
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Vertical"></VirtualizingStackPanel>
                    </ItemsPanelTemplate>
                </Setter>
            </Style>
        </Style>
        <Style Selector="^[TabStripPlacement=Left] /template/ Border#PART_BorderSeparator">
            <Setter Property="Width" Value="1" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>
        <Style Selector="^[TabStripPlacement=Left] /template/ ScrollViewer#PART_ScrollViewer">
            <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
            <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        </Style>
        <Style Selector="^[TabStripPlacement=Right] /template/ Border#PART_BorderSeparator">
            <Setter Property="Width" Value="1" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="Margin" Value="0 0 12 0"></Setter>
        </Style>
        <Style Selector="^[TabStripPlacement=Right] /template/ ScrollViewer#PART_ScrollViewer">
            <Setter Property="HorizontalScrollBarVisibility" Value="Disabled" />
            <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        </Style>
        <Style Selector="^[TabStripPlacement=Top] /template/ Border#PART_BorderSeparator">
            <Setter Property="Height" Value="1" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="Margin" Value="0 0 0 12"></Setter>
        </Style>
        <Style Selector="^[TabStripPlacement=Top] /template/ ScrollViewer#PART_ScrollViewer">
            <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
            <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
        </Style>
        <Style Selector="^[TabStripPlacement=Bottom] /template/ Border#PART_BorderSeparator">
            <Setter Property="Height" Value="1" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Top" />
        </Style>
        <Style Selector="^[TabStripPlacement=Bottom] /template/ ScrollViewer#PART_ScrollViewer">
            <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
            <Setter Property="VerticalScrollBarVisibility" Value="Disabled" />
        </Style>
    </ControlTheme>
</ResourceDictionary>
