<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Platform.Controls.TableContainer"
                    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">

    <local:MenuToIndentConverter x:Key="mtidc" />

    <Style x:Key="TreeViewItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="Expander_Style" TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Padding" Value="1,0,0,0" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="IsExpanded" Value="{Binding .IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        <Setter Property="IsSelected" Value="{Binding .IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border x:Name="Bd"
                                Grid.Row="0"
                                Margin="0.5,0"
                                Background="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TradeMenu},
                                                                                    AncestorLevel=1,
                                                                                    Mode=FindAncestor},
                                                     Path=ExpanderNormalBackground}"
                                BorderBrush="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TradeMenu},
                                                                                     AncestorLevel=1,
                                                                                     Mode=FindAncestor},
                                                      Path=ExpanderBroderBrush}"
                                BorderThickness="0,0,0,0.5"
                                CornerRadius="3">

                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              ContentSource="Header"
                                              RecognizesAccessKey="True" />
                        </Border>
                        <ItemsPresenter x:Name="ItemsHost"
                                        Grid.Row="1"
                                        Margin="{Binding Converter={StaticResource mtidc}}"
                                        Grid.IsSharedSizeScope="true"
                                        KeyboardNavigation.DirectionalNavigation="Cycle"
                                        KeyboardNavigation.TabNavigation="Cycle" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="false">
                            <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Bd" Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TradeMenu}, AncestorLevel=1, Mode=FindAncestor}, Path=ExpanderMoveOverBackground}" />
                        </Trigger>
                        <Trigger Property="HasItems" Value="false" />
                        <!--
                            <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                            </Trigger>
                        -->

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="true" />

                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:TradeMenu}, AncestorLevel=1, Mode=FindAncestor}, Path=ExpanderSelectedBackground}" />

                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel />
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--
        <Style x:Key="Expander_Style_Sub" TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Padding" Value="1,0,0,0" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}" />
        <Setter Property="Height" Value="Auto" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Template">
        <Setter.Value>
        <ControlTemplate TargetType="{x:Type TreeViewItem}">
        <Grid Background="WhiteSmoke">
        <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        </Grid.RowDefinitions>
        <Border x:Name="Bd"
        Grid.Row="0"
        Margin="0.5,0"
        BorderBrush="Gray"
        BorderThickness="1">
        <Border.Background>
        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Offset="0.221" Color="#FF51FF5C" />
        <GradientStop Color="#FF62D89A" />
        <GradientStop Offset="1" Color="#FF096013" />
        </LinearGradientBrush>
        </Border.Background>
        <ContentPresenter Margin="{TemplateBinding Padding}"
        ContentSource="Header"
        RecognizesAccessKey="True" />
        </Border>
        <ItemsPresenter x:Name="ItemsHost"
        Grid.Row="1"
        Grid.IsSharedSizeScope="true"
        KeyboardNavigation.DirectionalNavigation="Cycle"
        KeyboardNavigation.TabNavigation="Cycle" />
        </Grid>
        <ControlTemplate.Triggers>
        <Trigger Property="IsExpanded" Value="false">
        <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed" />
        </Trigger>
        <Trigger Property="IsMouseOver" Value="true">
        <Setter TargetName="Bd" Property="Background">
        <Setter.Value>
        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Offset="0.539" Color="#FF84F784" />
        <GradientStop Color="#FF9DFBCA" />
        <GradientStop Offset="1" Color="#FF6BFF7C" />
        </LinearGradientBrush>
        </Setter.Value>
        </Setter>
        </Trigger>
        <Trigger Property="HasItems" Value="false" />
        
        <Trigger Property="IsSelected" Value="true">
        <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
        </Trigger>
        
        <MultiTrigger>
        <MultiTrigger.Conditions>
        <Condition Property="IsSelected" Value="true" />
        <Condition Property="IsSelectionActive" Value="false" />
        </MultiTrigger.Conditions>
        <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        </MultiTrigger>
        <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
        </Trigger>
        </ControlTemplate.Triggers>
        </ControlTemplate>
        </Setter.Value>
        </Setter>
        <Style.Triggers>
        <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
        <Setter Property="ItemsPanel">
        <Setter.Value>
        <ItemsPanelTemplate>
        <VirtualizingStackPanel />
        </ItemsPanelTemplate>
        </Setter.Value>
        </Setter>
        </Trigger>
        </Style.Triggers>
        </Style>
    -->
</ResourceDictionary>