<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:dhcc="http://www.dhcc.com.cn"
                    xmlns:local="clr-namespace:Platform.Controls.TableContainer">

    <!--  region 需要的资源字典  -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Platform.Controls;component/Themes/MenuItemStyle.Generic.xaml" />
        <ResourceDictionary Source="/Platform.Controls;component/Themes/TreeViewItemStyle.Generic.xaml" />
        <ResourceDictionary Source="/Platform.Controls;component/Themes/ExpandeItemStyler.Generic.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <!--  endregion  -->

    <!--  region 画刷资源  -->

    <!--  endregion  -->

    <!--  region 默认层级模版  -->
    <!--  树形菜单默认层级模版  -->
    <HierarchicalDataTemplate x:Key="DefaultTreeViewTemplate" ItemsSource="{Binding Path=Children}">
        <StackPanel Orientation="Horizontal">
            <Image x:Name="img"
                   Width="16"
                   Height="16"
                   Margin="3,0,5,0"
                   Source="/Platform.Controls;component/Resource/9.ico"
                   Stretch="Fill"
                   Visibility="Visible" />
            <TextBlock x:Name="code"
                       Margin="0,0,5,0"
                       FontSize="12"
                       Text="{Binding Node.Code}" />

            <TextBlock x:Name="content"
                       FontSize="12"
                       Text="{Binding Node.Name}" />

        </StackPanel>
        <HierarchicalDataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsExpanded}" Value="true">
                <!--
                    <Setter TargetName="content" Property="Foreground" Value="Black" />
                    <Setter TargetName="code" Property="Foreground" Value="Black" />
                -->
                <Setter TargetName="img" Property="Source" Value="/Platform.Controls;component/Resource/3.ico" />
            </DataTrigger>
            <DataTrigger Binding="{Binding IsSelected}" Value="true">
                <!--
                    <Setter TargetName="content" Property="Foreground" Value="Black" />
                    <Setter TargetName="code" Property="Foreground" Value="Black" />
                -->
            </DataTrigger>
            <!--
                <DataTrigger Binding="{Binding Children}" Value="{x:Null}">
                <Setter TargetName="img" Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            -->
            <DataTrigger Binding="{Binding Children}" Value="{x:Null}">
                <Setter TargetName="img" Property="Source" Value="/Platform.Controls;component/Resource/sign.gif" />
                <Setter TargetName="img" Property="Margin" Value="0,0,2,0" />
            </DataTrigger>
        </HierarchicalDataTemplate.Triggers>
    </HierarchicalDataTemplate>

    <!--  展开条型菜单默认层级模版  -->
    <HierarchicalDataTemplate x:Key="DefaultExpanderTemplate"
                              DataType="{x:Type dhcc:TradeViewModel}"
                              ItemsSource="{Binding Path=Children}">
        <StackPanel Height="25" Orientation="Horizontal">
            <TextBlock x:Name="code"
                       Margin="3,0,5,0"
                       VerticalAlignment="Center"
                       FontSize="12"
                       Text="{Binding Node.Code}" />
            <TextBlock x:Name="content"
                       VerticalAlignment="Center"
                       FontSize="12"
                       Text="{Binding Node.Name}" />
        </StackPanel>
    </HierarchicalDataTemplate>

    <!--  菜单条型菜单默认层级模版  -->
    <HierarchicalDataTemplate x:Key="DefaultMenuTemplate" ItemsSource="{Binding Path=Children}">
        <StackPanel Orientation="Horizontal">
            <TextBlock x:Name="code"
                       Margin="0,0,5,0"
                       VerticalAlignment="Center"
                       FontSize="12"
                       Text="{Binding Node.Code}" />
            <TextBlock x:Name="content"
                       VerticalAlignment="Center"
                       FontSize="12"
                       Text="{Binding Node.Name}" />
        </StackPanel>
    </HierarchicalDataTemplate>
    <!--  endregion  -->

    <!--  region 模版选择器  -->
    <local:ItemTemplate x:Key="ItemTemplateSelector"
                        DefaultExpanderTemplate="{StaticResource DefaultExpanderTemplate}"
                        DefaultMenuTemplate="{StaticResource DefaultMenuTemplate}"
                        DefaultTreeViewTemplate="{StaticResource DefaultTreeViewTemplate}" />
    <!--  endregion  -->

    <!--  region TradeMenu样式选择  -->
    <Style TargetType="{x:Type local:TradeMenu}">
        <Style.Triggers>
            <!--  region 树形模板  -->
            <Trigger Property="TemplateType" Value="TreeView">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:TradeMenu}">
                            <Border>
                                <local:TreeViewForTrade x:Name="TradeTree"
                                                        Background="{DynamicResource MainPage_MenuTreeArea}"
                                                        BorderThickness="{TemplateBinding BorderThickness}"
                                                        ItemContainerStyle="{StaticResource TreeView_Style}"
                                                        ItemsSource="{TemplateBinding ItemsSource}"
                                                        ItemTemplateSelector="{StaticResource ItemTemplateSelector}"
                                                        Padding="0,8,0,0" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <!--  endregion  -->

            <!--  region 菜单模板  -->
            <Trigger Property="TemplateType" Value="Menu">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:TradeMenu}">
                            <Menu x:Name="TradeMenu"
                                  Background="{DynamicResource MainPage_MenuTreeArea}"
                                  ItemContainerStyle="{StaticResource Menu_Style}"
                                  ItemsSource="{TemplateBinding ItemsSource}"
                                  ItemTemplateSelector="{StaticResource ItemTemplateSelector}">
                                <Menu.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <VirtualizingStackPanel IsItemsHost="True" />
                                    </ItemsPanelTemplate>
                                </Menu.ItemsPanel>
                            </Menu>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <!--  endregion  -->

            <!--  region 展开条模板  -->
            <Trigger Property="TemplateType" Value="Expander">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type local:TradeMenu}">
                            <Border>
                                <local:TreeViewForTrade x:Name="TradeTree"
                                                        Background="{DynamicResource MainPage_MenuTreeArea}"
                                                        BorderThickness="{TemplateBinding BorderThickness}"
                                                        ItemContainerStyle="{StaticResource Expander_Style}"
                                                        ItemsSource="{TemplateBinding ItemsSource}"
                                                        ItemTemplateSelector="{StaticResource ItemTemplateSelector}" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <!--  endregion  -->
        </Style.Triggers>
    </Style>
    <!--  endregion  -->
</ResourceDictionary>