<Application x:Class="Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:behaviors="clr-namespace:PCL.Controls.Behaviors"
    xmlns:local="clr-namespace:PCL"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    StartupUri="FormMain.xaml"
    ShutdownMode="OnExplicitShutdown">
    <Application.Resources>
        <ResourceDictionary>
            
            <!-- Converter -->
            <local:AdditionConverter x:Key="AdditionConverter"/>
            <local:MultiplicationConverter x:Key="MultiplicationConverter"/>
            <local:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
            <local:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

            <!-- 颜色表 -->
            <SolidColorBrush x:Key="ColorBrush1">#343d4a</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush2">#0b5bcb</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush3">#1370f3</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush4">#4890f5</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush5">#96c0f9</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush6">#d5e6fd</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush7">#e0eafd</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrush8">#eaf2fe</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushBg0">#96c0f9</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushBg1">#bee0eafd</SolidColorBrush>
            <Color x:Key="ColorObject1">#343d4a</Color>
            <Color x:Key="ColorObject2">#0b5bcb</Color>
            <Color x:Key="ColorObject3">#1370f3</Color>
            <Color x:Key="ColorObject4">#4890f5</Color>
            <Color x:Key="ColorObject5">#96c0f9</Color>
            <Color x:Key="ColorObject6">#d5e6fd</Color>
            <Color x:Key="ColorObject7">#e0eafd</Color>
            <Color x:Key="ColorObject8">#eaf2fe</Color>
            <Color x:Key="ColorObjectBg0">#96c0f9</Color>
            <Color x:Key="ColorObjectBg1">#bee0eafd</Color>
            <SolidColorBrush x:Key="ColorBrushGray1">#404040</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray2">#737373</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray3">#8c8c8c</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray4">#a6a6a6</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray5">#cccccc</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray6">#ebebeb</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray7">#f0f0f0</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushGray8">#f5f5f5</SolidColorBrush>
            <Color x:Key="ColorObjectGray1">#404040</Color>
            <Color x:Key="ColorObjectGray2">#737373</Color>
            <Color x:Key="ColorObjectGray3">#8c8c8c</Color>
            <Color x:Key="ColorObjectGray4">#a6a6a6</Color>
            <Color x:Key="ColorObjectGray5">#cccccc</Color>
            <Color x:Key="ColorObjectGray6">#ebebeb</Color>
            <Color x:Key="ColorObjectGray7">#f0f0f0</Color>
            <Color x:Key="ColorObjectGray8">#f5f5f5</Color>
            <SolidColorBrush x:Key="ColorBrushRedBack">#80fbdddd</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushRedLight">#ff4c4c</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushRedDark">#ce2111</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushHalfWhite" Color="#55ffffff" />
            <SolidColorBrush x:Key="ColorBrushSemiWhite" Color="#bbffffff" />
            <SolidColorBrush x:Key="ColorBrushWhite" Color="#ffffff" />
            <SolidColorBrush x:Key="ColorBrushTransparent" Color="Transparent" />
            <SolidColorBrush x:Key="ColorBrushSemiTransparent">#01eaf2fe</SolidColorBrush>
            <SolidColorBrush x:Key="ColorBrushBackgroundTransparentSidebar" Color="#F1FFFFFF" />

            <!-- Window -->
            <Style TargetType="{x:Type Window}" x:Key="MyWindow">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Window}">
                            <ContentPresenter />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <!-- Label -->
            <Style TargetType="Label">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Padding" Value="0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Label">
                            <Border Background="{TemplateBinding Background}">
                                <ContentPresenter 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    Margin="{TemplateBinding Padding}" 
                                    RecognizesAccessKey="False" 
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="local:MyTextButton">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Padding" Value="0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Label">
                            <Border Background="{TemplateBinding Background}">
                                <TextBlock 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    Margin="{TemplateBinding Padding}" 
                                    Foreground="{TemplateBinding Foreground}"
                                    Text="{TemplateBinding Content}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            
            <!-- TextBlock -->
            <Style TargetType="TextBlock">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="FontSize" Value="13" />
                <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
                <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                <Setter Property="FontFamily" Value="Resources/#PCL English, Microsoft YaHei UI" />
            </Style>
            <Style TargetType="TextBlock" x:Key="BasedOnTextBlock">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="FontSize" Value="13" />
                <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
                <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                <Setter Property="FontFamily" Value="Resources/#PCL English, Microsoft YaHei UI" />
            </Style>

            <!-- ToolTip -->
            <Style TargetType="ToolTip">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Loaded="TooltipLoaded" Unloaded="TooltipUnloaded" BorderBrush="{DynamicResource ColorBrush1}" BorderThickness="1.5" CornerRadius="4" MaxWidth="500" Background="#E5FFFFFF" Margin="0,0,4,4" SnapsToDevicePixels="True">
                                <Border.Effect>
                                    <DropShadowEffect Opacity="0.3" BlurRadius="4" ShadowDepth="2" Color="{DynamicResource ColorObject1}" />
                                </Border.Effect>
                                <TextBlock Text="{TemplateBinding ContentControl.Content}" TextWrapping="Wrap" Foreground="{DynamicResource ColorBrush1}" Margin="7,5" FontSize="12"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="ExtendTextToolTip" TargetType="ToolTip">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Loaded="TooltipLoaded" Unloaded="TooltipUnloaded" BorderBrush="{DynamicResource ColorBrush1}" BorderThickness="1" CornerRadius="3" Background="White" Margin="0,0,4,4" SnapsToDevicePixels="True">
                                <TextBlock Text="{TemplateBinding ContentControl.Content}" TextWrapping="Wrap" Foreground="{DynamicResource ColorBrush1}" Margin="7,5" FontSize="12"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            
            <!-- ScrollViewer -->
            <Style x:Key="MyThumb" TargetType="Thumb">
                <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Thumb">
                            <Border Background="{StaticResource ColorBrushSemiTransparent}" SnapsToDevicePixels="True">
                                <Border Background="{TemplateBinding Foreground}" CornerRadius="3" Margin="2" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="local:MyScrollBar">
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False"/>
                <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="UseLayoutRounding" Value="True" />
                <Setter Property="MinWidth" Value="8"/>
                <Setter Property="Width" Value="8"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ScrollBar">
                            <Border CornerRadius="2">
                                <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}">
                                    <Track.Resources>
                                        <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">
                                            100
                                        </sys:Double>
                                    </Track.Resources>
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Opacity="0" />
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Opacity="0" />
                                    </Track.IncreaseRepeatButton> <!-- 不能删，删了点击 Thumb 以外的部分就不能翻页了 -->
                                    <Track.Thumb>
                                        <Thumb Style="{StaticResource MyThumb}" Foreground="{TemplateBinding Foreground}" />
                                    </Track.Thumb>
                                </Track>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="local:MyScrollViewer" x:Name="StyleMyScrollViewer">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="CanContentScroll" Value="False" />
                <Setter Property="PanningMode" Value="VerticalOnly" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ScrollViewer">
                            <Grid>
                                <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
                                <local:MyScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" HorizontalAlignment="Right" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="local:PageComp" BasedOn="{StaticResource {x:Type local:MyScrollViewer}}" />
            <Style TargetType="ScrollViewer" x:Key="ScrollViewerFullMargin">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="CanContentScroll" Value="False" />
                <Setter Property="PanningMode" Value="VerticalOnly" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ScrollViewer">
                            <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"/>
                                <local:MyScrollBar Margin="2,1,1,1" x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="ScrollViewer" x:Key="ScrollViewerNoMargin">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="CanContentScroll" Value="False" />
                <Setter Property="PanningMode" Value="VerticalOnly" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ScrollViewer">
                            <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" Cursor="Arrow">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Cursor="{TemplateBinding Cursor}" />
                                <local:MyScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Background}" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <!-- TextBox -->
            <Style TargetType="local:MyTextBox">
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="Background" Value="{StaticResource ColorBrushHalfWhite}" />
                <Setter Property="FontSize" Value="13" />
                <Setter Property="SelectionBrush" Value="{DynamicResource ColorBrush3}" />
                <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
                <Setter Property="FontFamily" Value="Resources/#PCL English, Microsoft YaHei UI" />
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="IsUndoEnabled" Value="True" />
                <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                <Setter Property="AllowDrop" Value="True"/>
                <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
                <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
                <Setter Property="UndoLimit" Value="15" />
                <Setter Property="MaxLength" Value="1000" />
                <Setter Property="BorderBrush" Value="{DynamicResource ColorBrushBg0}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="local:MyTextBox">
                            <Grid SnapsToDevicePixels="True" ToolTip="{TemplateBinding ToolTip}">
                                <Grid.RowDefinitions>
                                    <RowDefinition MinHeight="28" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}">
                                    <ScrollViewer x:Name="PART_ContentHost" Style="{StaticResource ScrollViewerNoMargin}" RenderOptions.ClearTypeHint="Enabled" BorderThickness="0"
                                           Margin="5,0,0,0" Cursor="IBeam" />
                                    <!-- 由于未知原因，TextView 会有 2,0 的 Margin -->
                                </Border>
                                <Border Margin="{TemplateBinding Padding}" IsHitTestVisible="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" BorderThickness="0">
                                    <TextBlock x:Name="labHint" Foreground="{StaticResource ColorBrushGray4}" Margin="7,0,0,0" Padding="{TemplateBinding BorderThickness}" FontSize="{TemplateBinding FontSize}" FontFamily="Resources/#PCL English, Microsoft YaHei UI" />
                                </Border>
                                <TextBlock Grid.Row="1" x:Name="labWrong" Height="0" Foreground="{TemplateBinding BorderBrush}" Padding="0,4,0,0" Margin="0,0,0,-3" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="behaviors:ClipboardInterceptor.EnableSafeClipboard" Value="True" />
            </Style>
            <Style TargetType="PasswordBox">
                <Setter Property="FontSize" Value="13" />
                <Setter Property="VerticalContentAlignment" Value="Top" />
                <Setter Property="SelectionBrush" Value="{DynamicResource ColorBrush3}" />
                <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
                <Setter Property="Background" Value="{StaticResource ColorBrushHalfWhite}" />
                <Setter Property="BorderBrush" Value="{DynamicResource ColorBrushBg0}" />
                <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="PasswordBox">
                            <Border x:Name="border" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="True" CornerRadius="3">
                                <local:MyScrollViewer x:Name="PART_ContentHost" Margin="4.5,4.5,0,4.5" HorizontalScrollBarVisibility="Hidden" RenderOptions.ClearTypeHint="Enabled" SnapsToDevicePixels="True"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Trigger.Setters>
                                        <Setter Property="BorderBrush" Value="{StaticResource ColorBrushGray5}" />
                                        <Setter Property="Background" Value="{StaticResource ColorBrushGray6}" />
                                    </Trigger.Setters>
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.Setters>
                                        <Setter Property="BorderBrush" Value="{DynamicResource ColorBrush4}" />
                                        <Setter Property="Background" Value="{DynamicResource ColorBrush7}" />
                                    </Trigger.Setters>
                                </Trigger>
                                <Trigger Property="IsFocused" Value="True">
                                    <Trigger.Setters>
                                        <Setter Property="BorderBrush" Value="{DynamicResource ColorBrush3}" />
                                        <Setter Property="Background" Value="{DynamicResource ColorBrush7}" />
                                    </Trigger.Setters>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="behaviors:ClipboardInterceptor.EnableSafeClipboard" Value="True" />
            </Style>

            <!-- ComboBox -->
            <DataTemplate x:Key="ComboBoxItemTemplateWithDelete">
                <local:MyListItem Title="{Binding}" FontSize="13" MaxHeight="26" IsScaleAnimationEnabled="False" Margin="-3,0,0,0">
                    <local:MyListItem.Buttons>
                        <x:Array Type="local:MyIconButton">
                            <local:MyIconButton Grid.Column="1" Height="20" Width="20" VerticalAlignment="Center" Tag="{Binding}" Click="MyIconButton_Click" Logo="F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z" />
                        </x:Array>
                    </local:MyListItem.Buttons>
                </local:MyListItem>
            </DataTemplate>
            <Style TargetType="local:MyComboBox">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="Foreground" Value="{DynamicResource ColorBrushBg0}" />
                <Setter Property="Background" Value="{StaticResource ColorBrushHalfWhite}" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="FontSize" Value="13" />
                <Setter Property="MaxDropDownHeight" Value="160" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ComboBox">
                            <Grid>
                                <Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="3" BorderThickness="1" BorderBrush="{TemplateBinding Foreground}" />
                                <ToggleButton Margin="0,0,1.5,0" Foreground="{TemplateBinding Foreground}" IsTabStop="False" SnapsToDevicePixels="False" Focusable="False" IsChecked="{Binding IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />
                                <ContentPresenter x:Name="PART_Content" Margin="8.5,0,21.5,0" IsHitTestVisible="False" VerticalAlignment="Center"
                                                  Content="{TemplateBinding SelectionBoxItem}" 
                                                  ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" 
                                                  ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" />
                                <Popup x:Name="PART_Popup" SnapsToDevicePixels="True" VerticalOffset="-1.5" AllowsTransparency="True" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="Fade">
                                    <Grid x:Name="PanPopup">
                                        <Border Background="White" CornerRadius="3" />
                                        <Border x:Name="dropDownBorder" CornerRadius="3" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" Width="{TemplateBinding Width}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                            <local:MyScrollViewer x:Name="DropDownScrollViewer" PanningMode="VerticalOnly" SnapsToDevicePixels="False" Style="{StaticResource ScrollViewerFullMargin}" ScrollViewer.CanContentScroll="False" VerticalScrollBarVisibility="Auto">
                                                <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" />
                                            </local:MyScrollViewer>
                                        </Border>
                                    </Grid>
                                </Popup>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="HasItems" Value="false">
                                    <Setter Property="Height" TargetName="dropDownBorder" Value="26"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsEditable" Value="True">
                        <Setter Property="IsTabStop" Value="False"/>
                        <Setter Property="ItemTemplate" Value="{StaticResource ComboBoxItemTemplateWithDelete}"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ComboBox">
                                    <Grid>
                                        <Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="3" BorderThickness="1" BorderBrush="{TemplateBinding Foreground}" />
                                        <ToggleButton Margin="0,0,1.5,0" Foreground="{TemplateBinding Foreground}" IsTabStop="False" SnapsToDevicePixels="False" Focusable="False" IsChecked="{Binding IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" />
                                        <local:MyTextBox x:Name="PART_EditableTextBox" BorderThickness="0" Margin="1.5,0,21.5,0" Padding="0" Background="{x:Null}" />
                                        <Popup x:Name="PART_Popup" SnapsToDevicePixels="True" VerticalOffset="-1.5" AllowsTransparency="True" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="Fade">
                                            <Grid x:Name="PanPopup">
                                                <Border Background="White" CornerRadius="3" />
                                                <Border x:Name="dropDownBorder" SnapsToDevicePixels="False" CornerRadius="3" BorderBrush="{TemplateBinding Foreground}" BorderThickness="1" Width="{TemplateBinding Width}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                                    <local:MyScrollViewer x:Name="DropDownScrollViewer" Style="{StaticResource ScrollViewerFullMargin}" ScrollViewer.CanContentScroll="False" VerticalScrollBarVisibility="Auto">
                                                        <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" />
                                                    </local:MyScrollViewer>
                                                </Border>
                                            </Grid>
                                        </Popup>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="HasItems" Value="false">
                                            <Setter Property="Height" TargetName="dropDownBorder" Value="26"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style TargetType="ToggleButton">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ToggleButton">
                            <Border Background="{StaticResource ColorBrushSemiTransparent}">
                                <Path x:Name="path" Width="15" RenderTransformOrigin="0.3,0.5" HorizontalAlignment="Right" Data="M1,1L4.5,4.5L8,1" StrokeThickness="1.5" Stroke="{TemplateBinding Foreground}" VerticalAlignment="Center">
                                    <Path.RenderTransform>
                                        <RotateTransform />
                                    </Path.RenderTransform>
                                </Path>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)">
                                                <DoubleAnimation To="180" Duration="0:0:0.2">
                                                    <DoubleAnimation.EasingFunction>
                                                        <CircleEase EasingMode="EaseOut" />
                                                    </DoubleAnimation.EasingFunction>
                                                </DoubleAnimation>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard  Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)">
                                                <DoubleAnimation To="0" Duration="0:0:0.2">
                                                    <DoubleAnimation.EasingFunction>
                                                        <CircleEase EasingMode="EaseOut" />
                                                    </DoubleAnimation.EasingFunction>
                                                </DoubleAnimation>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="ComboBoxItem" x:Key="MyComboBoxItem">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="ToolTipService.Placement" Value="Relative" />
                <Setter Property="ToolTipService.VerticalOffset" Value="-2" />
                <Setter Property="ToolTipService.HorizontalOffset" Value="200" />
                <Setter Property="ToolTipService.InitialShowDelay" Value="150" />
                <Setter Property="ToolTipService.BetweenShowDelay" Value="150" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="Background" Value="{StaticResource ColorBrushTransparent}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ComboBoxItem">
                            <Border x:Name="ItemBorder" Padding="6,4" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
                                <ContentPresenter />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="ComboBoxItem">
                <Setter Property="OverridesDefaultStyle" Value="True" />
                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ComboBoxItem">
                            <Border x:Name="ItemBorder" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
                                <ContentPresenter />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <!-- ContextMenu -->
            <Style TargetType="ContextMenu">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="True"/>
                <Setter Property="Focusable" Value="False"/>
                <Setter Property="HasDropShadow" Value="False"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ContextMenu">
                            <Border BorderBrush="{DynamicResource ColorBrush1}" BorderThickness="1" CornerRadius="3" Background="White" Margin="0,0,4,4" SnapsToDevicePixels="True">
                                <Border.Effect>
                                    <DropShadowEffect Opacity="0.4" BlurRadius="4" ShadowDepth="2" />
                                </Border.Effect>
                                <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Margin="0.5"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <!-- MenuItem -->
            <Style TargetType="local:MyMenuItem">
                <Setter Property="Foreground" Value="{DynamicResource ColorBrush1}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="MenuItem">
                            <Border Name="PanBack" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Height="26">
                                <Grid SnapsToDevicePixels="False" UseLayoutRounding="False">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                                        <ColumnDefinition />
                                        <!--  <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                                    <ColumnDefinition Width="13"/>  -->
                                    </Grid.ColumnDefinitions>
                                    <Path Name="Icon" VerticalAlignment="Center" Stretch="Uniform" Margin="8,0" Fill="{TemplateBinding Foreground}" Height="12" Width="15" />
                                    <TextBlock Name="HeaderHost" Grid.Column="1" Text="{TemplateBinding Header}" Foreground="{TemplateBinding Foreground}" Margin="0,0,40,0" VerticalAlignment="Center" Height="16" />
                                    <!--  <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,2,0,2" DockPanel.Dock="Right" /> -->
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="Icon" Value="{x:Null}">
                                    <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            
        </ResourceDictionary>
    </Application.Resources>
</Application>
