<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:helper="clr-namespace:Platform.Controls.ControlsHelper"
                    xmlns:dhcc="http://www.dhcc.com.cn"
                    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
 
    <LinearGradientBrush x:Key="ButtonNormalBackground" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Offset="0" Color="#F3F3F3" />
        <GradientStop Offset="0.5" Color="#EBEBEB" />
        <GradientStop Offset="0.5" Color="#DDDDDD" />
        <GradientStop Offset="1" Color="#CDCDCD" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070" />
    <Geometry x:Key="DownArrowGeometry">M 0 0 L 3.5 4 L 7 0 Z</Geometry>
    <Style x:Key="ComboBox_ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="20" />
                        </Grid.ColumnDefinitions>
                        <Border Name="Bd"
                                Grid.ColumnSpan="2"
                                Background="{DynamicResource ComboBoxButton_Normal_Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="2">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="20" />
                                </Grid.ColumnDefinitions>
                                <Border x:Name="Border"
                                        Grid.Column="1"
                                        Background="Transparent"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="0"
                                        CornerRadius="2"
                                        Cursor="Hand" />
                            </Grid>
                        </Border>
                        <Border Name="Main_Border"
                                Grid.Column="0"
                                Margin="1"
                                Background="{DynamicResource ComboBoxText_Normal_Background}"
                                BorderBrush="Transparent"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="2,0,0,2"
                                Cursor="Hand" />
                        <Path x:Name="Arrow"
                              Grid.Column="1"
                              Margin="0,0,3,0"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Cursor="Hand"
                              Data="M 0 0 L 4 4 L 8 0 Z"
                              Fill="#FF848484" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="Main_Border" Property="IsMouseOver" Value="true">
                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ComboBox_MouseOver_Foreground}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ComboBox_MouseOver_BorderBrush}" />
                        </Trigger>
                        <Trigger SourceName="Border" Property="IsMouseOver" Value="true">
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ComboBox_MouseOver_BorderBrush}" />
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ComboBoxButton_MouseOver_Background}" />
                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ComboBox_MouseOver_Foreground}" />
                        </Trigger>
                        <Trigger SourceName="Arrow" Property="IsMouseOver" Value="true">
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ComboBox_MouseOver_BorderBrush}" />
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ComboBoxButton_MouseOver_Background}" />
                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ComboBox_MouseOver_Foreground}" />
                        </Trigger>
                        <Trigger Property="ToggleButton.IsChecked" Value="true">
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ComboBox_Check_BorderBrush}" />
                            <Setter TargetName="Bd" Property="BorderThickness" Value="{DynamicResource ComboBox_Check_BorderThickness}" />
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ComboBox_Check_Background}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Main_Border" Property="Background" Value="{DynamicResource ComboBox_Enable_Background}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ComboBox_Enable_BorderBrush}" />
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ComboBox_Enable_Background}" />
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ComboBox_Enable_Background}" />
                            <Setter Property="Foreground" Value="{DynamicResource ComboBox_Enable_Foreground}" />
                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ComboBox_Enable_Foreground}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <LinearGradientBrush x:Key="TextBoxBorder" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,20">
        <GradientStop Offset="0.05" Color="#ABADB3" />
        <GradientStop Offset="0.07" Color="#E2E3EA" />
        <GradientStop Offset="1" Color="#E3E9EF" />
    </LinearGradientBrush>
    <ControlTemplate x:Key="ComboBox_ComboBoxTextBox" TargetType="TextBox">
        <Border Background="{TemplateBinding Background}"
                CornerRadius="10"
                Focusable="False">
            <ScrollViewer x:Name="PART_ContentHost" />
        </Border>
    </ControlTemplate>
    <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="ClickMode" Value="Press" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome"
                                                           Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
                                                           Background="{TemplateBinding Background}"
                                                           BorderBrush="{TemplateBinding BorderBrush}"
                                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                                           RenderPressed="{TemplateBinding IsPressed}"
                                                           RoundCorners="false"
                                                           SnapsToDevicePixels="true">
                        <Path x:Name="Arrow"
                              Margin="0,1,0,0"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="{StaticResource DownArrowGeometry}"
                              Fill="Black" />
                    </Microsoft_Windows_Themes:ButtonChrome>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Chrome" Property="RenderPressed" Value="true" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Arrow" Property="Fill" Value="#AFAFAF" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type local:ComboBoxDataGrid}">
        <Grid x:Name="Placement" SnapsToDevicePixels="true">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Popup x:Name="PART_Popup"
                   Grid.ColumnSpan="2"
                   AllowsTransparency="true"
                   IsOpen="{Binding IsDropDownOpen,
                                    RelativeSource={RelativeSource TemplatedParent}}"
                   Placement="Bottom"
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
                <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw"
                                                                 MinWidth="{Binding ActualWidth,
                                                                                    ElementName=Placement}"
                                                                 MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                                                 Color="Transparent">
                    <Border x:Name="DropDownBorder"
                            Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
                            BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"
                            BorderThickness="1">
                        <local:DHCCDataGrid x:Name="PART_PopupDataGrid"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                  AutoGenerateColumns="False"
                                  CanUserSortColumns="True"
                                  DisplayMemberPath="{TemplateBinding DisplayMemberPath}"
                                  Focusable="False"
                                  HeadersVisibility="Column"
                                  IsReadOnly="True"
                                  IsSynchronizedWithCurrentItem="False"
                                  IsTextSearchEnabled="{TemplateBinding IsTextSearchEnabled}"
                                  ItemsSource="{TemplateBinding ItemsSource}"
                                  RowDetailsVisibilityMode="Collapsed"
                                  SelectedIndex="{TemplateBinding SelectedIndex}"
                                  SelectedItem="{TemplateBinding SelectedItem}"
                                  SelectedValue="{TemplateBinding SelectedValue}"
                                  SelectedValuePath="{TemplateBinding SelectedValuePath}"
                                  SelectionMode="Single"
                                  Tag="{TemplateBinding Tag}" />

                    </Border>
                </Microsoft_Windows_Themes:SystemDropShadowChrome>
            </Popup>
            <Microsoft_Windows_Themes:ListBoxChrome x:Name="Border"
                                                    Grid.ColumnSpan="2"
                                                    Background="{TemplateBinding Background}"
                                                    BorderBrush="{TemplateBinding BorderBrush}"
                                                    BorderThickness="{TemplateBinding BorderThickness}"
                                                    RenderFocused="{TemplateBinding IsKeyboardFocusWithin}"
                                                    RenderMouseOver="{TemplateBinding IsMouseOver}" />
            <TextBox x:Name="PART_EditableTextBox"
                     Margin="{TemplateBinding Padding}"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Center"
                     Background="Transparent"
                     Focusable="True"
                     IsReadOnly="{TemplateBinding IsReadOnly}"
                     Style="{x:Null}"
                     Template="{StaticResource ComboBox_ComboBoxTextBox}"
                     />
            <ToggleButton Grid.Column="1"
                          IsChecked="{Binding IsDropDownOpen,
                                              Mode=TwoWay,
                                              RelativeSource={RelativeSource TemplatedParent}}"
                          Style="{StaticResource ComboBoxToggleButton}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsKeyboardFocusWithin" Value="true">
                <Setter Property="Foreground" Value="Black" />
            </Trigger>
            <Trigger Property="IsDropDownOpen" Value="true">
                <Setter TargetName="Border" Property="RenderFocused" Value="true" />
            </Trigger>
            <Trigger Property="HasItems" Value="false">
                <Setter TargetName="DropDownBorder" Property="Height" Value="95" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                <Setter Property="Background" Value="#FFF4F4F4" />
            </Trigger>
            <Trigger Property="IsGrouping" Value="true">
                <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
            </Trigger>
            <Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true">
                <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />
                <Setter TargetName="Shdw" Property="Color" Value="#71000000" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style TargetType="{x:Type local:ComboBoxDataGrid}" BasedOn="{StaticResource {x:Type ComboBox}}">
        <Setter Property="Height" Value="{DynamicResource GroupBox_Normal_Height}" />
        <Setter Property="Width" Value="{DynamicResource GroupBox_Normal_Width}" />
        <Setter Property="HorizontalAlignment" Value="{DynamicResource ComboBox_Normal_HorizontalAlignment}" />
        <Setter Property="VerticalAlignment" Value="{DynamicResource ComboBox_Normal_VerticalAlignment}" />
        <Setter Property="dhcc:FocusManager.FocusHandled" Value="{x:Static helper:ComboBoxHelper.ComboBoxFocusHandled}" />
        <Setter Property="dhcc:FocusManager.IsInternalKeyboardControlling" Value="True" />
        <Setter Property="dhcc:FocusManagerExt.IsFocusAdorner" Value="True" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="Padding" Value="4,3" />
        <Setter Property="dhcc:FocusManagerExt.ValidationField" Value="SelectedValue" />
        <!--  ComboBox 循环遍历元素  -->
        <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle" />
        <Setter Property="dhcc:FocusManagerExt.FieldEmptyPolicies">
            <Setter.Value>
                <dhcc:FieldPolicyCollection>
                    <dhcc:ShowTipPolicy Placement="Right" />
                </dhcc:FieldPolicyCollection>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ComboBoxDataGrid}">
                    <Grid x:Name="MainGrid" Focusable="False">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
                        </Grid.ColumnDefinitions>
                        <Popup x:Name="PART_Popup"
                               Grid.ColumnSpan="2"
                               Margin="1"
                               AllowsTransparency="true"
                               IsOpen="{Binding IsDropDownOpen,
                                                RelativeSource={RelativeSource TemplatedParent}}"
                               Placement="Bottom"
                               PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
                            <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw"
                                                                             MinWidth="{Binding ActualWidth,
                                                                                                ElementName=MainGrid}"
                                                                             MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                                                             Color="Transparent">
                                <Border x:Name="DropDownBorder"
                                        Background="{DynamicResource ComboBoxDropdown_Normal_Background}"
                                        BorderBrush="{DynamicResource ComboBoxDropdown_Normal_BorderBrush}"
                                        BorderThickness="{DynamicResource ComboBoxDropdown_Normal_BorderThickness}"
                                        Focusable="False" >
                                    <local:DHCCDataGrid x:Name="PART_PopupDataGrid"
                                              MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                              AutoGenerateColumns="False"
                                              CanUserSortColumns="False"
                                              DisplayMemberPath="{TemplateBinding DisplayMemberPath}"
                                              Focusable="False"
                                              HeadersVisibility="Column"
                                              IsReadOnly="True"
                                              IsSynchronizedWithCurrentItem="False"
                                              IsTextSearchEnabled="{TemplateBinding IsTextSearchEnabled}"
                                              ItemsSource="{TemplateBinding ItemsSource}"
                                              RowDetailsVisibilityMode="Collapsed"
                                              SelectedIndex="{TemplateBinding SelectedIndex}"
                                              SelectedItem="{TemplateBinding SelectedItem}"
                                              SelectedValue="{TemplateBinding SelectedValue}"
                                              SelectedValuePath="{TemplateBinding SelectedValuePath}"
                                              SelectionMode="Single"
                                              Tag="{TemplateBinding Tag}" />
                                </Border>
                            </Microsoft_Windows_Themes:SystemDropShadowChrome>
                        </Popup>
                        <ToggleButton Grid.ColumnSpan="2"
                                      Background="{DynamicResource ComboBox_Normal_Background}"
                                      BorderBrush="#FFBCBDBD"
                                      BorderThickness="1"
                                      ClickMode="Press"
                                      Focusable="false"
                                      IsChecked="{Binding Path=IsDropDownOpen,
                                                          Mode=TwoWay,
                                                          RelativeSource={RelativeSource TemplatedParent}}"
                                      Style="{StaticResource ComboBox_ComboBoxToggleButton}" />
                        <ContentPresenter Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          IsHitTestVisible="False"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true">
                            <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />
                            <Setter TargetName="Shdw" Property="Color" Value="#71000000" />
                        </Trigger>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="DropDownBorder" Property="Height" Value="95" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                            <Setter Property="Background" Value="#FFF4F4F4" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEditable" Value="true">
                <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}" />
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
                <Setter Property="IsTabStop" Value="false" />
                <Setter Property="Padding" Value="3" />
                <Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <!--  Resource dictionary entries should be defined here.  -->

</ResourceDictionary>