<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"
                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    mc:Ignorable="d">

    <Style TargetType="{x:Type TreeView}" BasedOn="{StaticResource BaseStyle}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="BorderThickness" Value="{DynamicResource ControlBorderThickness}" />
        <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeView}">
                    <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
                            CornerRadius="{DynamicResource ControlCornerRadius}">
                        <ScrollViewer Focusable="False" Padding="4"
                                      HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                      VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource BaseStyle}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}" />
        <Setter Property="Padding" Value="0,2,4,2" />
        <Setter Property="Margin" Value="0,1,0,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <StackPanel>
                        <Border x:Name="SelectionBorder" Background="Transparent"
                                Padding="{TemplateBinding Padding}" Margin="{TemplateBinding Margin}">
                            <DockPanel>
                                <ToggleButton x:Name="Expander" ClickMode="Press" DockPanel.Dock="Left"
                                              IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}">
                                    <ToggleButton.Style>
                                        <Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource BaseStyle}">
                                            <Setter Property="Focusable" Value="False" />
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                        <Grid>
                                                            <Viewbox x:Name="IsExpandedPath" Visibility="Visible" >
                                                                <TextBlock Text="4" FontFamily="Marlett" Foreground="{DynamicResource TextBrush}"
                                                                           HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                            </Viewbox>
                                                            <Viewbox x:Name="ExpandPath" Visibility="Collapsed" >
                                                                <TextBlock Text="6" FontFamily="Marlett" Foreground="{DynamicResource TextBrush}"
                                                                           HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                            </Viewbox>
                                                        </Grid>
                                                        <ControlTemplate.Triggers>
                                                            <Trigger Property="IsChecked" Value="True">
                                                                <Setter Property="Visibility" Value="Visible" TargetName="ExpandPath" />
                                                                <Setter Property="Visibility" Value="Collapsed" TargetName="IsExpandedPath" />
                                                            </Trigger>
                                                        </ControlTemplate.Triggers>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </ToggleButton.Style>
                                </ToggleButton>
                                <ContentPresenter x:Name="PART_Header" ContentSource="Header" Height="Auto"
                                                  DockPanel.Dock="Left"/>
                            </DockPanel>
                        </Border>
                        <ItemsPresenter x:Name="ItemsHost" Margin="20,0,0,0" />
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ItemsHost" />
                        </Trigger>
                        <Trigger Property="HasItems" Value="False">
                            <Setter Property="Visibility" Value="Hidden" TargetName="Expander" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="{DynamicResource GlyphBrush}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="SelectionBorder">
                            <Setter Property="Foreground" Value="{DynamicResource GlyphBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>