<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:smart="clr-namespace:SmartUI.Controls"
                    xmlns:base="clr-namespace:SmartUI.Base"
                    xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding">
    <Style x:Key="CascaderDefaultStyle" TargetType="{x:Type smart:Cascader}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBorderGaryColor}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Width" Value="150"/>
        <Setter Property="Height" Value="35"/>
        <Setter Property="Margin" Value="0 3"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextColor}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Padding" Value="2" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="IsDropDownOpen" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type smart:Cascader}">
                    <Grid>
                        <Border x:Name="border" Background="White" Margin="0 0 5 0" ToolTip="{TemplateBinding Text}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4">
                            <DockPanel LastChildFill="True" VerticalAlignment="Center" Cursor="Hand">
                                <smart:PackIcon x:Name="icon" DockPanel.Dock="Right" Width="16" Height="16" Kind="KeyboardArrowDown" Foreground="{TemplateBinding BorderBrush}" Margin="5"/>
                                <TextBlock Text="{TemplateBinding Text}" Margin="5 0" VerticalAlignment="Center"/>
                            </DockPanel>
                        </Border>
                        <Popup x:Name="popup" IsOpen="{TemplateBinding IsDropDownOpen}" MinWidth="150" Height="Auto" HorizontalAlignment="Left" VerticalOffset="1" MinHeight="100" MaxHeight="300" AllowsTransparency="True">
                            <Border Background="White" CornerRadius="4" Padding="1 0" Margin="0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1">
                                <Border.Effect>
                                    <DropShadowEffect Color="LightGray" Opacity="0.3"/>
                                </Border.Effect>
                                <StackPanel x:Name="Pack_items" Orientation="Horizontal">
                                    <StackPanel.Resources>
                                        <Style TargetType="ListBox">
                                            <Setter Property="Width" Value="140"/>
                                            <Setter Property="Height" Value="{Binding ElementName=popup,Path=Height}"/>
                                            <Setter Property="BorderBrush" Value="{DynamicResource BorderBaseColor}"/>
                                            <Setter Property="BorderThickness" Value="0"/>
                                            <Setter Property="SelectionMode" Value="Single"/>
                                            <Setter Property="ItemsPanel">
                                                <Setter.Value>
                                                    <ItemsPanelTemplate>
                                                        <StackPanel Orientation="Vertical"/>
                                                    </ItemsPanelTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                        <Style TargetType="ListBoxItem">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate>
                                                        <DockPanel x:Name="dock" LastChildFill="True" Height="30">
                                                            <smart:PackIcon x:Name="icon" Kind="KeyboardArrowRight" DockPanel.Dock="Right" Width="16" Height="16" VerticalAlignment="Center" Margin="5 0"/>
                                                            <Label Name="lable" Foreground="{DynamicResource PrimaryTextColor}" IsHitTestVisible="True" Content="{Binding DisplayName}" Padding="5 0"/>
                                                        </DockPanel>
                                                        <ControlTemplate.Triggers>
                                                            <Trigger SourceName="dock" Property="IsMouseOver" Value="True">
                                                                <Setter TargetName="dock" Property="Background" Value="{DynamicResource BgHoverColor}"/>
                                                            </Trigger>
                                                            <DataTrigger Binding="{Binding Children.Count}" Value="0">
                                                                <Setter TargetName="icon" Property="Visibility" Value="Collapsed"/>
                                                            </DataTrigger>
                                                            <DataTrigger Binding="{Binding Children}" Value="{x:Null}">
                                                                <Setter TargetName="icon" Property="Visibility" Value="Collapsed"/>
                                                            </DataTrigger>
                                                            <DataTrigger Binding="{Binding IsChecked}" Value="True">
                                                                <Setter TargetName="lable" Property="Foreground" Value="{DynamicResource BrandColor}"/>
                                                                <Setter TargetName="icon" Property="Foreground" Value="{DynamicResource BrandColor}"/>
                                                            </DataTrigger>
                                                        </ControlTemplate.Triggers>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </StackPanel.Resources>
                                </StackPanel>
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDropDownOpen" Value="True">
                            <Setter TargetName="icon" Property="Kind" Value="KeyboardArrowUp"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type smart:Cascader}" BasedOn="{StaticResource CascaderDefaultStyle}"/>
</ResourceDictionary>