<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    mc:Ignorable="d">
    
    <Style TargetType="{x:Type Sidebar}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Sidebar}">
                    <Border BorderThickness="0,0,1,0" BorderBrush="{DynamicResource PanelSeparatorBrush}"
                            x:Name="BorderContentHolder" Margin="{TemplateBinding Padding}">
                        <DockPanel x:Name="DockContentHolder">                            
                            <Border x:Name="PART_ElemMainMenu" Background="Transparent"
                                    Width="44" Height="44" Margin="0,0,0,5"
                                    DockPanel.Dock="Top" Padding="5" Cursor="Hand"
                                    WindowChrome.IsHitTestVisibleInChrome="True">
                                <Image Source="{ThemeFile 'Images/applogo.png'}"
                                       RenderOptions.BitmapScalingMode="Fant" />
                            </Border>

                            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden"
                                          DockPanel.Dock="Top" CanContentScroll="True"
                                          x:Name="ScrollSidebarItems">
                                <StackPanel x:Name="PART_PanelSideBarItems" Orientation="Vertical" />
                            </ScrollViewer> 
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Settings SidebarPosition}" Value="Right">
                            <Setter Property="Padding" Value="0,25,0,0" />
                            <Setter Property="Margin" Value="0,0,0,5" TargetName="PART_ElemMainMenu" />
                            <Setter Property="BorderThickness" Value="1,0,0,0" TargetName="BorderContentHolder" />
                        </DataTrigger>
                        <DataTrigger Binding="{Settings SidebarPosition}" Value="Top">
                            <Setter Property="Margin" Value="0,0,5,0" TargetName="PART_ElemMainMenu" />
                            <Setter Property="BorderThickness" Value="0,0,0,1" TargetName="BorderContentHolder" />
                            <Setter Property="DockPanel.Dock" Value="Left" TargetName="PART_ElemMainMenu" />
                            <Setter Property="DockPanel.Dock" Value="Left" TargetName="ScrollSidebarItems" />
                            <Setter Property="Margin" Value="0,0,100,0" TargetName="ScrollSidebarItems" />
                            <Setter Property="Orientation" Value="Horizontal" TargetName="PART_PanelSideBarItems" />
                        </DataTrigger>
                        <DataTrigger Binding="{Settings SidebarPosition}" Value="Bottom">
                            <Setter Property="Margin" Value="0,0,5,0" TargetName="PART_ElemMainMenu" />
                            <Setter Property="BorderThickness" Value="0,1,0,0" TargetName="BorderContentHolder" />
                            <Setter Property="DockPanel.Dock" Value="Left" TargetName="PART_ElemMainMenu" />
                            <Setter Property="DockPanel.Dock" Value="Left" TargetName="ScrollSidebarItems" />
                            <Setter Property="Orientation" Value="Horizontal" TargetName="PART_PanelSideBarItems" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>