<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ModernWpf.Controls"
    xmlns:primitives="clr-namespace:ModernWpf.Controls.Primitives"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Common.xaml" />
        <ResourceDictionary Source="TextBox.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <primitives:CornerRadiusFilterConverter x:Key="TopLeftCornerRadiusDoubleValueConverter" Filter="TopLeftValue" />
    <primitives:CornerRadiusFilterConverter x:Key="BottomRightCornerRadiusDoubleValueConverter" Filter="BottomRightValue" />

    <sys:Double x:Key="ComboBoxArrowThemeFontSize">21</sys:Double>
    <sys:Double x:Key="ComboBoxThemeMinWidth">64</sys:Double>
    <sys:Double x:Key="ComboBoxPopupThemeMinWidth">80</sys:Double>
    <sys:Double x:Key="ComboBoxPopupThemeTouchMinWidth">240</sys:Double>
    <sys:Double x:Key="ComboBoxItemPillHeight">16</sys:Double>
    <sys:Double x:Key="ComboBoxItemPillWidth">3</sys:Double>
    <sys:Double x:Key="ComboBoxItemPillMinScale">0.625</sys:Double>
    <sys:Double x:Key="ComboBoxMinHeight">32</sys:Double>

    <sys:Int32 x:Key="ComboBoxPopupMaxNumberOfItems">15</sys:Int32>
    <sys:Int32 x:Key="ComboBoxPopupMaxNumberOfItemsThatCanBeShownOnOneSide">7</sys:Int32>

    <sys:String x:Key="ComboBoxItemScaleAnimationDuration">00:00:00.167</sys:String>

    <Thickness x:Key="ComboBoxBorderThemeThickness">1</Thickness>
    <Thickness x:Key="ComboBoxDropdownBorderThickness">1</Thickness>
    <Thickness x:Key="ComboBoxHeaderThemeMargin">0,0,0,4</Thickness>
    <Thickness x:Key="ComboBoxPopupBorderThemeThickness">2</Thickness>
    <Thickness x:Key="ComboBoxItemThemePadding">11,5,11,7</Thickness>
    <Thickness x:Key="ComboBoxItemThemeTouchPadding">11,11,11,13</Thickness>
    <Thickness x:Key="ComboBoxItemThemeGameControllerPadding">11,11,11,13</Thickness>
    <Thickness x:Key="ComboBoxBackgroundBorderThicknessFocused">2</Thickness>
    <Thickness x:Key="ComboBoxDropdownContentMargin">0,4</Thickness>
    <Thickness x:Key="ComboBoxTopHeaderMargin">0,0,0,8</Thickness>
    <Thickness x:Key="ComboBoxPadding">12,5,0,7</Thickness>
    <Thickness x:Key="ComboBoxEditableTextPadding">11,5,38,6</Thickness>

    <CornerRadius x:Key="ComboBoxHiglightBorderCornerRadius">7</CornerRadius>
    <CornerRadius x:Key="ComboBoxDropDownButtonBackgroundCornerRadius">4</CornerRadius>
    <CornerRadius x:Key="ComboBoxItemCornerRadius">3</CornerRadius>
    <CornerRadius x:Key="ComboBoxItemPillCornerRadius">1.5</CornerRadius>

    <FontWeight x:Key="ComboBoxHeaderThemeFontWeight">Normal</FontWeight>
    <FontWeight x:Key="ComboBoxPlaceholderTextThemeFontWeight">350</FontWeight>

    <Style x:Key="ComboBoxItemPill" TargetType="Rectangle">
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Height" Value="{StaticResource ComboBoxItemPillHeight}"/>
        <Setter Property="Width" Value="{StaticResource ComboBoxItemPillWidth}"/>
        <Setter Property="Fill" Value="{DynamicResource ComboBoxItemPillFillBrush}"/>
        <Setter Property="RadiusX" Value="{Binding Source={StaticResource ComboBoxItemPillCornerRadius}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"/>
        <Setter Property="RadiusY" Value="{Binding Source={StaticResource ComboBoxItemPillCornerRadius}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}"/>
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
    </Style>

    <Style x:Key="DefaultComboBoxItemStyle" TargetType="ComboBoxItem">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Foreground" Value="{DynamicResource ComboBoxItemForeground}" />
        <Setter Property="Background" Value="{DynamicResource ComboBoxItemBackground}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
        <Setter Property="Padding" Value="{DynamicResource ComboBoxItemThemePadding}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="True" />
        <Setter Property="primitives:FocusVisualHelper.FocusVisualMargin" Value="-3" />
        <Setter Property="primitives:ControlHelper.CornerRadius" Value="{StaticResource ComboBoxItemCornerRadius}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border
                        x:Name="LayoutRoot"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Margin="5,2,5,2"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                        SnapsToDevicePixels="True">

                        <Grid>
                            <Rectangle
                                x:Name="Pill"
                                Style="{StaticResource ComboBoxItemPill}"
                                Grid.Row="1" Grid.Column="0"
                                Opacity="0">
                                <Rectangle.RenderTransform>
                                    <ScaleTransform x:Name="PillTransform" ScaleY="1"/>
                                </Rectangle.RenderTransform>
                            </Rectangle>

                            <ContentPresenter
                                x:Name="ContentPresenter"
                                TextElement.Foreground="{TemplateBinding Foreground}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Margin="{TemplateBinding Padding}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="False" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPointerOver}" />
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPointerOver}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundPointerOver}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="False" />
                                <Condition Property="IsEnabled" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundDisabled}" />
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushDisabled}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundDisabled}" />
                        </MultiTrigger>
                        <!-- Selected -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsFocused" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Pill" Property="Opacity" Value="1" />
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelected}" />
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelected}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelected}" />
                        </MultiTrigger>
                        <!-- SelectedUnfocused -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsFocused" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Pill" Property="Opacity" Value="1" />
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedUnfocused}" />
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedUnfocused}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedUnfocused}" />
                        </MultiTrigger>
                        <!-- SelectedDisabled -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsEnabled" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Pill" Property="Opacity" Value="1" />
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedDisabled}" />
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedDisabled}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedDisabled}" />
                        </MultiTrigger>
                        <!-- SelectedPointerOver -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Pill" Property="Opacity" Value="1" />
                            <Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPointerOver}" />
                            <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPointerOver}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPointerOver}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ComboBoxItem" BasedOn="{StaticResource DefaultComboBoxItemStyle}" />

    <Style x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="ClickMode" Value="Release" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Border
                        Background="{TemplateBinding Background}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                        SnapsToDevicePixels="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ComboBoxTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource DefaultTextBoxStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                    <Grid SnapsToDevicePixels="True">
                        <Border
                            x:Name="BorderElement"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
                        <ScrollViewer
                            x:Name="PART_ContentHost"
                            Style="{DynamicResource TextControlContentHostStyle}"
                            Margin="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                            VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                            IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                            IsTabStop="False" />
                        <TextBlock
                            x:Name="PlaceholderTextContentPresenter"
                            Foreground="{DynamicResource TextControlPlaceholderForeground}"
                            Margin="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            Text="{TemplateBinding primitives:ControlHelper.PlaceholderText}"
                            TextAlignment="{TemplateBinding TextAlignment}"
                            TextWrapping="{TemplateBinding TextWrapping}"
                            IsHitTestVisible="False"
                            Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="BorderElement" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
                            <Setter TargetName="BorderElement" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
                            <Setter TargetName="PART_ContentHost" Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
                            <Setter TargetName="PlaceholderTextContentPresenter" Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundDisabled}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="BorderElement" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
                            <Setter TargetName="BorderElement" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushPointerOver}" />
                            <Setter TargetName="PART_ContentHost" Property="Foreground" Value="{DynamicResource TextControlForegroundPointerOver}" />
                            <Setter TargetName="PlaceholderTextContentPresenter" Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundPointerOver}" />
                        </Trigger>
                        <Trigger Property="IsSelectionActive" Value="True">
                            <Setter TargetName="BorderElement" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
                            <Setter TargetName="BorderElement" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushFocused}" />
                            <Setter TargetName="BorderElement" Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThicknessFocused}" />
                            <Setter Property="Foreground" Value="{DynamicResource TextControlForegroundFocused}" />
                            <Setter Property="CaretBrush" Value="{DynamicResource TextControlForegroundFocused}" />
                            <Setter TargetName="PlaceholderTextContentPresenter" Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundFocused}" />
                        </Trigger>
                        <Trigger Property="Text" Value="">
                            <Setter TargetName="PlaceholderTextContentPresenter" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultComboBoxStyle" TargetType="ComboBox">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" />
        <Setter Property="MaxDropDownHeight" Value="504" />
        <Setter Property="Foreground" Value="{DynamicResource ComboBoxForeground}" />
        <Setter Property="Background" Value="{DynamicResource ComboBoxBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource ComboBoxBorderThemeThickness}" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Once" />
        <Setter Property="primitives:ComboBoxHelper.TextBoxStyle" Value="{StaticResource ComboBoxTextBoxStyle}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="primitives:ControlHelper.PlaceholderForeground" Value="{DynamicResource ComboBoxPlaceHolderForeground}" />
        <Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource IsApplicationFocusVisualKindReveal}" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="primitives:ComboBoxHelper.KeepInteriorCornersSquare" Value="True" />
        <Setter Property="primitives:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource TextControlValidationErrorTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <ControlTemplate.Resources>
                        <StreamGeometry x:Key="ChevronDown">M 18.935547 4.560547 L 19.814453 5.439453 L 10 15.253906 L 0.185547 5.439453 L 1.064453 4.560547 L 10 13.496094 Z</StreamGeometry>
                    </ControlTemplate.Resources>

                    <Grid
                        x:Name="LayoutRoot"
                        SnapsToDevicePixels="True">
                        <Grid.Resources>
                            <Storyboard x:Key="OverlayOpeningAnimation">
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Shdw" Storyboard.TargetProperty="Opacity">
                                    <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="0.0" />
                                    <SplineDoubleKeyFrame KeyTime="{StaticResource ControlNormalAnimationDuration}" KeySpline="{StaticResource ControlFastOutSlowInKeySpline}" Value="1.0" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </Grid.Resources>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="38" />
                        </Grid.ColumnDefinitions>

                        <local:ContentPresenterEx
                            x:Name="HeaderContentPresenter"
                            Grid.Row="0"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            Content="{TemplateBinding primitives:ControlHelper.Header}"
                            ContentTemplate="{TemplateBinding primitives:ControlHelper.HeaderTemplate}"
                            FlowDirection="{TemplateBinding FlowDirection}"
                            Foreground="{DynamicResource ComboBoxHeaderForeground}"
                            FontWeight="{DynamicResource ComboBoxHeaderThemeFontWeight}"
                            Margin="{DynamicResource ComboBoxTopHeaderMargin}"
                            TextWrapping="Wrap"
                            VerticalAlignment="Top"
                            Visibility="{TemplateBinding primitives:ControlHelper.HeaderVisibility}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        <Border x:Name="HighlightBackground"
                            Grid.Row="1"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            Margin="-4"
                            Background="{DynamicResource ComboBoxBackgroundFocused}"
                            BorderBrush="{DynamicResource ComboBoxBackgroundBorderBrushFocused}"
                            BorderThickness="{StaticResource ComboBoxBackgroundBorderThicknessFocused}"
                            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                            Opacity="0" />

                        <Border
                            x:Name="Background"
                            Grid.Row="1"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                            MinWidth="{DynamicResource ComboBoxThemeMinWidth}"
                            primitives:ValidationHelper.IsTemplateValidationAdornerSite="True" />

                        <Rectangle x:Name="Pill"
                            Style="{StaticResource ComboBoxItemPill}"
                            Margin="1,0,0,0"
                            Grid.Row="1" Grid.Column="0"
                            Opacity="0">
                            <Rectangle.RenderTransform>
                                <ScaleTransform x:Name="PillTransform" ScaleY="1" />
                            </Rectangle.RenderTransform>
                        </Rectangle>

                        <ContentPresenter
                            x:Name="ContentPresenter"
                            Grid.Row="1"
                            Grid.Column="0"
                            Margin="{TemplateBinding Padding}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Content="{TemplateBinding SelectionBoxItem}"
                            ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                            ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                            ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <TextBlock
                            x:Name="PlaceholderTextBlock"
                            Grid.Row="1"
                            Grid.Column="0"
                            Margin="{TemplateBinding Padding}"
                            Padding="0,0,32,0"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Text="{TemplateBinding primitives:ControlHelper.PlaceholderText}"
                            Foreground="{TemplateBinding primitives:ControlHelper.PlaceholderForeground}"
                            IsHitTestVisible="False"
                            Visibility="Collapsed" />
                        <ToggleButton
                            x:Name="ToggleButton"
                            IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                            Grid.Row="1"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            Style="{StaticResource ComboBoxToggleButton}"
                            Background="Transparent" />
                        <TextBox
                            x:Name="PART_EditableTextBox"
                            Grid.Row="1"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            IsReadOnly="{TemplateBinding IsReadOnly}"
                            Style="{TemplateBinding primitives:ComboBoxHelper.TextBoxStyle}"
                            Margin="0,0,0,0"
                            Padding="{DynamicResource ComboBoxEditableTextPadding}"
                            BorderBrush="Transparent"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            primitives:ControlHelper.PlaceholderText="{TemplateBinding primitives:ControlHelper.PlaceholderText}"
                            primitives:ControlHelper.PlaceholderForeground="{TemplateBinding primitives:ControlHelper.PlaceholderForeground}"
                            Visibility="Collapsed"
                            AutomationProperties.Name="{TemplateBinding AutomationProperties.Name}"
                            primitives:ControlHelper.CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}" />
                        <ToggleButton
                            x:Name="DropDownOverlay"
                            IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                            Style="{StaticResource ComboBoxToggleButton}"
                            Grid.Row="1"
                            Grid.Column="1"
                            Background="Transparent"
                            Margin="-4,4,4,4"
                            Visibility="Collapsed"
                            primitives:ControlHelper.CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}"
                            Width="30"
                            HorizontalAlignment="Right" />
                        <local:FontIconFallback
                            x:Name="DropDownGlyph"
                            MinHeight="{DynamicResource ComboBoxMinHeight}"
                            Grid.Row="1"
                            Grid.Column="1"
                            IsHitTestVisible="False"
                            Margin="0,0,12,0"
                            Foreground="{DynamicResource ComboBoxDropDownGlyphForeground}"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Width="16"
                            Height="16"
                            FontFamily="{DynamicResource SymbolThemeFontFamily}"
                            FontSize="12"
                            Data="{StaticResource ChevronDown}" />
                        <ContentPresenter
                            x:Name="DescriptionPresenter"
                            Grid.Row="2"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            TextElement.Foreground="{DynamicResource SystemControlDescriptionTextForegroundBrush}"
                            Content="{TemplateBinding primitives:ControlHelper.Description}"
                            Visibility="{TemplateBinding primitives:ControlHelper.DescriptionVisibility}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Popup
                            x:Name="PART_Popup"
                            AllowsTransparency="True"
                            Placement="Bottom"
                            PlacementTarget="{Binding ElementName=Background}"
                            IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
                            PopupAnimation="None">
                            <Popup.PlacementRectangle>
                                <MultiBinding>
                                    <MultiBinding.Converter>
                                        <primitives:PlacementRectangleConverter Margin="0,1,0,1" />
                                    </MultiBinding.Converter>
                                    <Binding ElementName="Background" Path="ActualWidth" />
                                    <Binding ElementName="Background" Path="ActualHeight" />
                                </MultiBinding>
                            </Popup.PlacementRectangle>
                            <primitives:ThemeShadowChrome
                                x:Name="Shdw"
                                MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                MinWidth="{Binding ActualWidth, ElementName=LayoutRoot}"
                                IsShadowEnabled="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"
                                CornerRadius="{Binding ElementName=PopupBorder, Path=CornerRadius}"
                                primitives:OpeningAnimationHelper.Storyboard="{StaticResource OverlayOpeningAnimation}">
                                <Border
                                    x:Name="PopupBorder"
                                    Background="{DynamicResource ComboBoxDropDownBackground}"
                                    BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}"
                                    BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}"
                                    Margin="0,-0.5,0,-1"
                                    Padding="{DynamicResource ComboBoxDropdownBorderPadding}"
                                    HorizontalAlignment="Stretch"
                                    CornerRadius="{DynamicResource OverlayCornerRadius}">
                                    <ScrollViewer
                                        x:Name="ScrollViewer"
                                        Foreground="{DynamicResource ComboBoxDropDownForeground}"
                                        HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                        VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                        IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}">
                                        <ItemsPresenter
                                            Margin="{DynamicResource ComboBoxDropdownContentMargin}"
                                            KeyboardNavigation.DirectionalNavigation="Contained"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                    </ScrollViewer>
                                </Border>
                            </primitives:ThemeShadowChrome>
                        </Popup>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <!-- PointerOver -->
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{DynamicResource ComboBoxBackgroundPointerOver}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundPointerOver}" />
                            <Setter TargetName="PlaceholderTextBlock" Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundPointerOver}" />
                        </Trigger>
                        <!-- Pressed -->
                        <Trigger SourceName="ToggleButton" Property="IsPressed" Value="True">
                            <Setter TargetName="Background" Property="Background" Value="{DynamicResource ComboBoxBackgroundPressed}" />
                            <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPressed}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundPressed}" />
                            <Setter TargetName="PlaceholderTextBlock" Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundPressed}" />
                        </Trigger>
                        <!-- Disabled -->
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Background" Property="Background" Value="{DynamicResource ComboBoxBackgroundDisabled}" />
                            <Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushDisabled}" />
                            <Setter TargetName="HeaderContentPresenter" Property="Foreground" Value="{DynamicResource ComboBoxHeaderForegroundDisabled}" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundDisabled}" />
                            <Setter TargetName="PlaceholderTextBlock" Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundDisabled}" />
                            <Setter TargetName="DropDownGlyph" Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundDisabled}" />
                        </Trigger>

                        <!-- Focused -->
                        <Trigger Property="primitives:FocusVisualHelper.ShowFocusVisual" Value="True">
                            <Setter TargetName="HighlightBackground" Property="Opacity" Value="1" />
                            <Setter TargetName="Pill" Property="Opacity" Value="1" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundFocused}" />
                            <Setter TargetName="PlaceholderTextBlock" Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocused}" />
                            <Setter TargetName="DropDownGlyph" Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocused}" />
                        </Trigger>
                        <!-- FocusedPressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="primitives:FocusVisualHelper.ShowFocusVisual" Value="True" />
                                <Condition SourceName="ToggleButton" Property="IsPressed" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="HighlightBackground" Property="Opacity" Value="1" />
                            <Setter TargetName="Pill" Property="Opacity" Value="1" />
                            <Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxForegroundFocusedPressed}" />
                            <Setter TargetName="PlaceholderTextBlock" Property="Foreground" Value="{DynamicResource ComboBoxPlaceHolderForegroundFocusedPressed}" />
                            <Setter TargetName="DropDownGlyph" Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForegroundFocusedPressed}" />
                        </MultiTrigger>
                        <!-- FocusedDropDown -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="primitives:FocusVisualHelper.ShowFocusVisual" Value="True" />
                                <Condition Property="IsDropDownOpen" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PopupBorder" Property="Visibility" Value="Visible" />
                        </MultiTrigger>

                        <Trigger Property="IsEditable" Value="true">
                            <Setter TargetName="ContentPresenter" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="ToggleButton" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
                            <Setter TargetName="DropDownOverlay" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsEditable" Value="False" />
                                <Condition Property="SelectedIndex" Value="-1" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
                        </MultiTrigger>

                        <!-- TextBoxFocused -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="PART_EditableTextBox" Property="IsSelectionActive" Value="True" />
                                <Condition SourceName="DropDownOverlay" Property="IsMouseOver" Value="False" />
                                <Condition SourceName="DropDownOverlay" Property="IsPressed" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="DropDownGlyph" Property="Foreground" Value="{DynamicResource ComboBoxEditableDropDownGlyphForeground}" />
                        </MultiTrigger>
                        <!-- TextBoxFocusedOverlayPointerOver -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="PART_EditableTextBox" Property="IsSelectionActive" Value="True" />
                                <Condition SourceName="DropDownOverlay" Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="DropDownGlyph" Property="Foreground" Value="{DynamicResource ComboBoxEditableDropDownGlyphForeground}" />
                            <Setter TargetName="DropDownOverlay" Property="Background" Value="{DynamicResource ComboBoxDropDownBackgroundPointerOver}" />
                        </MultiTrigger>
                        <!-- TextBoxFocusedOverlayPressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="PART_EditableTextBox" Property="IsSelectionActive" Value="True" />
                                <Condition SourceName="DropDownOverlay" Property="IsPressed" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="DropDownGlyph" Property="Foreground" Value="{DynamicResource ComboBoxEditableDropDownGlyphForeground}" />
                            <Setter TargetName="DropDownOverlay" Property="Background" Value="{DynamicResource ComboBoxFocusedDropDownBackgroundPointerPressed}" />
                            <Setter TargetName="DropDownOverlay" Property="Margin" Value="0,2,2,2" />
                        </MultiTrigger>
                        <!-- TextBoxOverlayPointerOver -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="PART_EditableTextBox" Property="IsSelectionActive" Value="False" />
                                <Condition SourceName="DropDownOverlay" Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="DropDownOverlay" Property="Background" Value="{DynamicResource ComboBoxDropDownBackgroundPointerOver}" />
                        </MultiTrigger>
                        <!-- TextBoxOverlayPressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="PART_EditableTextBox" Property="IsSelectionActive" Value="False" />
                                <Condition SourceName="DropDownOverlay" Property="IsPressed" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="DropDownOverlay" Property="Background" Value="{DynamicResource ComboBoxDropDownBackgroundPointerPressed}" />
                        </MultiTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsGrouping" Value="true" />
                                <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ComboBox" BasedOn="{StaticResource DefaultComboBoxStyle}" />

    <Style x:Key="DataGridComboBoxStyle" TargetType="ComboBox" BasedOn="{StaticResource DefaultComboBoxStyle}">
        <Setter Property="Padding" Value="12,0,0,0" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="primitives:ControlHelper.CornerRadius" Value="0" />
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource DataGridTextControlValidationErrorTemplate}" />
    </Style>

    <Style x:Key="DataGridTextBlockComboBoxStyle" TargetType="ComboBox" BasedOn="{StaticResource DefaultComboBoxStyle}">
        <Setter Property="Padding" Value="12,0,0,0" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <ContentPresenter
                        Margin="{TemplateBinding Padding}"
                        Content="{TemplateBinding SelectionBoxItem}"
                        ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                        ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                        ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                        IsHitTestVisible="false" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>