<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">
    <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="{DynamicResource ComboBoxButton_Normal_Foreground}" />
                    </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="Main_Border" Property="dhcc:FocusManagerExt.AssertNotEmpty" Value="True">
                            <Setter TargetName="Main_Border" Property="Background" Value="{DynamicResource TextBox_AssertNotEmpty_Background}" />
                        </Trigger>
                        <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>
    <ControlTemplate x:Key="ComboBox_ComboBoxTextBox" TargetType="TextBox">
        <Border Background="{TemplateBinding Background}"
                CornerRadius="10"
                Focusable="False">
            <ScrollViewer x:Name="PART_ContentHost" />
        </Border>
    </ControlTemplate>

    <Style BasedOn="{StaticResource {x:Type ComboBox}}" TargetType="{x:Type ComboBox}">
        <Style.Resources>
            <dhcc:IndexOfIListConverter x:Key="GetIndex" />
        </Style.Resources>
        <Setter Property="dhcc:FocusManager.FocusHandled" Value="{x:Static dhcc:ComboBoxHelper.ComboBoxFocusHandled}" />
        <Setter Property="dhcc:FocusManager.MouseFocusHandled" Value="{x:Static dhcc:ComboBoxHelper.ComboBoxHandled}" />
        <Setter Property="dhcc:FocusManager.IsInternalKeyboardControlling" Value="True" />
        <Setter Property="dhcc:FocusManagerExt.IsFocusAdorner" Value="True" />
        <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="SelectedValuePath" Value="Value" />
        <Setter Property="IsEditable" Value="false" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <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="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <StackPanel HorizontalAlignment="Stretch"
                                Background="Transparent"
                                Orientation="Horizontal">
                        <TextBlock Width="Auto" Text="[" />
                        <TextBlock Width="Auto">
                            <TextBlock.Text>
                                <MultiBinding Converter="{StaticResource GetIndex}">
                                    <Binding Path="Items" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ComboBox}}" />
                                    <Binding />
                                </MultiBinding>
                            </TextBlock.Text>
                        </TextBlock>
                        <TextBlock Width="Auto" Text="]" />
                        <TextBlock Text="{Binding Mode=OneTime, Path=Key}" />
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <!--  <MultiBinding StringFormat="{}[{0}]{1}">  -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid>
                        <ToggleButton Name="ToggleButton"
                                      Grid.Column="2"
                                      Background="{DynamicResource ComboBox_Normal_Background}"
                                      BorderBrush="{DynamicResource ComboBox_Normal_BorderBrush}"
                                      BorderThickness="{DynamicResource ComboBox_Normal_BorderThickness}"
                                      ClickMode="Press"
                                      Focusable="false"
                                      IsChecked="{Binding Path=IsDropDownOpen,
                                                          Mode=TwoWay,
                                                          RelativeSource={RelativeSource TemplatedParent}}"
                                      Style="{StaticResource ComboBox_ComboBoxToggleButton}" />

                        <ContentPresenter Name="ContentSite"
                                          Margin="3,3,23,3"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Center"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          IsHitTestVisible="False" />
                        <TextBox x:Name="PART_EditableTextBox"
                                 Margin="3,3,23,3"
                                 HorizontalAlignment="Left"
                                 VerticalAlignment="Center"
                                 Background="Transparent"
                                 Focusable="True"
                                 IsReadOnly="{TemplateBinding IsReadOnly}"
                                 Style="{x:Null}"
                                 Template="{StaticResource ComboBox_ComboBoxTextBox}"
                                 Visibility="Hidden" />
                        <Popup Name="Popup"
                               AllowsTransparency="True"
                               Focusable="False"
                               IsOpen="{TemplateBinding IsDropDownOpen}"
                               Placement="Bottom"
                               PopupAnimation="Slide">
                            <Grid Name="DropDown"
                                  MinWidth="{TemplateBinding ActualWidth}"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                  SnapsToDevicePixels="True">
                                <Border x:Name="DropDownBorder"
                                        Background="{DynamicResource ComboBoxDropdown_Normal_Background}"
                                        BorderBrush="{DynamicResource ComboBoxDropdown_Normal_BorderBrush}"
                                        BorderThickness="{DynamicResource ComboBoxDropdown_Normal_BorderThickness}" />
                                <ScrollViewer Margin="0,2,0,0"
                                              FocusVisualStyle="{x:Null}"
                                              HorizontalScrollBarVisibility="Auto"
                                              SnapsToDevicePixels="True">
                                    <StackPanel Margin="1,1,1,1"
                                                IsItemsHost="True"
                                                KeyboardNavigation.DirectionalNavigation="Contained" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource ComboBox_Enable_Foreground}" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </Trigger>
                        <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
                            <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0" />
                            <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
                        </Trigger>
                        <Trigger Property="IsEditable" Value="true">
                            <Setter Property="IsTabStop" Value="false" />
                            <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
                            <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden" />
                        </Trigger>
                        <Trigger Property="Width" Value="Auto">
                            <Setter Property="MinWidth" Value="120" />
                        </Trigger>
                        <Trigger Property="Height" Value="Auto">
                            <Setter Property="MinHeight" Value="20" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers />
    </Style>
    <Style TargetType="{x:Type ComboBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border Name="Border"
                            Padding="2"
                            SnapsToDevicePixels="true">
                        <ContentPresenter />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource ComboBoxItem_Select_Background}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource ComboBoxItem_Enable_Foreground}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!--  AutoComplete  -->
    <Style x:Key="AutoCompleteComboBox" TargetType="ComboBox">
        <Setter Property="dhcc:FocusManager.FocusHandled" Value="{x:Static dhcc:ComboBoxHelper.ComboBoxNormalFocusHandled}" />
        <Setter Property="dhcc:FocusManager.MouseFocusHandled" Value="{x:Static dhcc:ComboBoxHelper.ComboBoxHandled}" />
        <Setter Property="dhcc:FocusManager.IsInternalKeyboardControlling" Value="True" />
        <Setter Property="dhcc:FocusManagerExt.IsFocusAdorner" Value="True" />
        <Setter Property="IsTextSearchEnabled" Value="False" />
        <Setter Property="SelectedValuePath" Value="Value" />
        <Setter Property="DisplayMemberPath" Value="Key" />
        <Setter Property="IsEditable" Value="True" />
        <Setter Property="MaxDropDownHeight" Value="200" />
        <Setter Property="IsSynchronizedWithCurrentItem" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="dhcc:FocusManagerExt.ValidationField" Value="SelectedValue" />
        <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="ComboBox">
                    <Grid>
                        <ToggleButton Name="ToggleButton"
                                      Grid.Column="2"
                                      Background="{DynamicResource ComboBox_Normal_Background}"
                                      BorderBrush="{DynamicResource ComboBox_Normal_BorderBrush}"
                                      BorderThickness="{DynamicResource ComboBox_Normal_BorderThickness}"
                                      ClickMode="Press"
                                      Focusable="false"
                                      IsChecked="{Binding Path=IsDropDownOpen,
                                                          Mode=TwoWay,
                                                          RelativeSource={RelativeSource TemplatedParent}}"
                                      Style="{StaticResource ComboBox_ComboBoxToggleButton}" />
                        <ContentPresenter Name="ContentSite"
                                          Margin="3,3,23,3"
                                          HorizontalAlignment="Left"
                                          VerticalAlignment="Center"
                                          Content="{TemplateBinding SelectionBoxItem}"
                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                          IsHitTestVisible="False" />
                        <TextBox x:Name="PART_EditableTextBox"
                                 Margin="3,3,23,3"
                                 HorizontalAlignment="Left"
                                 VerticalAlignment="Center"
                                 Background="Transparent"
                                 Focusable="True"
                                 IsHitTestVisible="False"
                                 IsReadOnly="{TemplateBinding IsReadOnly}"
                                 Style="{x:Null}"
                                 Template="{StaticResource ComboBox_ComboBoxTextBox}"
                                 Visibility="Hidden" />
                        <Popup Name="Popup"
                               AllowsTransparency="True"
                               Focusable="False"
                               IsOpen="{TemplateBinding IsDropDownOpen}"
                               Placement="Bottom"
                               PopupAnimation="Slide">
                            <Grid Name="DropDown"
                                  MinWidth="{TemplateBinding ActualWidth}"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                  SnapsToDevicePixels="True">
                                <Border x:Name="DropDownBorder"
                                        Background="{DynamicResource ComboBoxDropdown_Normal_Background}"
                                        BorderBrush="{DynamicResource ComboBoxDropdown_Normal_BorderBrush}"
                                        BorderThickness="{DynamicResource ComboBoxDropdown_Normal_BorderThickness}" />
                                <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
                                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                                </ScrollViewer>
                            </Grid>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasItems" Value="false">
                            <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource ComboBox_Enable_Foreground}" />
                        </Trigger>
                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </Trigger>
                        <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
                            <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0" />
                            <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
                        </Trigger>
                        <Trigger Property="IsEditable" Value="true">
                            <Setter Property="IsTabStop" Value="false" />
                            <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
                            <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden" />
                        </Trigger>
                        <Trigger Property="Width" Value="Auto">
                            <Setter Property="MinWidth" Value="120" />
                        </Trigger>
                        <Trigger Property="Height" Value="Auto">
                            <Setter Property="MinHeight" Value="20" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>