<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:c="clr-namespace:ScreenToGif.Controls"
                    xmlns:v="clr-namespace:ScreenToGif.Util.Converters">

    <!--ComboBox Style-->
    <Style x:Key="Style.ToggleButton.ComboBox" 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="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border x:Name="templateRoot" BorderBrush="{DynamicResource Element.Border}" BorderThickness="1" Background="{DynamicResource Element.Background}">
                        <Border x:Name="splitBorder" BorderBrush="Transparent" BorderThickness="1" HorizontalAlignment="Right" Margin="0" 
                                SnapsToDevicePixels="True" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
                            <Path x:Name="arrow" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z" 
                                  Fill="{DynamicResource Element.Glyph}" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center"/>
                        </Border>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" TargetName="arrow" Value="{DynamicResource Element.Glyph.Hover}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Fill" TargetName="arrow" Value="{DynamicResource Element.Glyph.Pressed}"/>
                        </Trigger>

                        <!--Editable, !Hovered-->
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="True"/>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="False"/>
                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="False"/>
                            </MultiDataTrigger.Conditions>

                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background}"/>
                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource Element.Border}"/>
                            <Setter Property="Background" TargetName="splitBorder" Value="Transparent"/>
                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="Transparent"/>
                        </MultiDataTrigger>

                        <!--Editable, Hovered-->
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="True"/>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True"/>
                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="False"/>
                            </MultiDataTrigger.Conditions>

                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background.Hover}"/>
                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource Element.Border.Hover}"/>
                            <Setter Property="Background" TargetName="splitBorder" Value="{DynamicResource Element.Background.Hover}"/>
                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="{DynamicResource Element.Border.Hover}"/>
                        </MultiDataTrigger>

                        <!--Editable, Pressed-->
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="True"/>
                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="True"/>
                            </MultiDataTrigger.Conditions>

                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background.Pressed}"/>
                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource Element.Border.Pressed}"/>
                            <Setter Property="Background" TargetName="splitBorder" Value="{DynamicResource Element.Background.Pressed}"/>
                            <Setter Property="BorderBrush" TargetName="splitBorder" Value="{DynamicResource Element.Border.Pressed}"/>
                        </MultiDataTrigger>

                        <!--!Editable, Hovered-->
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="False"/>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True"/>
                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="False"/>
                            </MultiDataTrigger.Conditions>

                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background.Hover}"/>
                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource Element.Border.Hover}"/>
                        </MultiDataTrigger>

                        <!--!Editable, Pressed-->
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="False"/>
                                <Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="True"/>
                            </MultiDataTrigger.Conditions>

                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background.Pressed}"/>
                            <Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource Element.Border.Pressed}"/>
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="Style.TextBox.ComboBoxEditable" TargetType="{x:Type c:ExtendedTextBox}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="AllowDrop" Value="True"/>
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Foreground" Value="{DynamicResource Element.Foreground}"/>
        <Setter Property="CaretBrush" Value="{DynamicResource Element.Foreground}"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type c:ExtendedTextBox}">
                    <ScrollViewer x:Name="PART_ContentHost" Background="Transparent" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    
    <ControlTemplate x:Key="Template.ComboBox" TargetType="{x:Type ComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
            </Grid.ColumnDefinitions>

            <Popup Grid.ColumnSpan="2" x:Name="PART_Popup" AllowsTransparency="True" Placement="Bottom"
                   IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">

                <Border x:Name="DropDownBorder" BorderBrush="{DynamicResource Element.Border}" BorderThickness="1" Background="{DynamicResource Element.Background}" Effect="{DynamicResource Shadow.Border}"
                        MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
                    <ScrollViewer x:Name="DropDownScrollViewer">
                        <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </ScrollViewer>
                </Border>
            </Popup>

            <ToggleButton Grid.Column="0" Grid.ColumnSpan="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" 
                          IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource Style.ToggleButton.ComboBox}"/>

            <ContentPresenter Grid.Column="0" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" 
                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter TargetName="DropDownBorder" Property="Height" Value="95"/>
            </Trigger>

            <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>

    <ControlTemplate x:Key="Template.ComboBox.Editable" TargetType="{x:Type ComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
            </Grid.ColumnDefinitions>

            <Popup Grid.ColumnSpan="2" x:Name="PART_Popup" AllowsTransparency="True" Placement="Bottom"
                   IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">

                <Border x:Name="DropDownBorder" BorderBrush="{DynamicResource Element.Border}" BorderThickness="1" Background="{DynamicResource Element.Background}" Effect="{DynamicResource Shadow.Border}"
                        MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
                    <ScrollViewer x:Name="DropDownScrollViewer">
                        <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </ScrollViewer>
                </Border>
            </Popup>

            <ToggleButton Grid.Column="0" Grid.ColumnSpan="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" 
                          IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource Style.ToggleButton.ComboBox}"/>

            <c:ExtendedTextBox Grid.Column="0" x:Name="PART_EditableTextBox" Margin="{TemplateBinding Padding}"
                               IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource Style.TextBox.ComboBoxEditable}" 
                               HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" TargetName="PART_EditableTextBox" Value="0.7"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource Element.Foreground}"/>
            </Trigger>
            <Trigger Property="HasItems" Value="False">
                <Setter TargetName="DropDownBorder" Property="Height" Value="95"/>
            </Trigger>

            <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>


    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="FocusVisualStyle" Value="{DynamicResource Style.FocusVisual.NoMargin}"/>
        <Setter Property="Height" Value="25"/>
        <Setter Property="Background" Value="{DynamicResource Element.Background}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Element.Border}"/>
        <Setter Property="Foreground" Value="{DynamicResource Element.Foreground}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="Padding" Value="5,3"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template" Value="{StaticResource Template.ComboBox}"/>

        <Style.Triggers>
            <Trigger Property="IsEditable" Value="True">
                <Setter Property="IsTabStop" Value="False"/>
                <Setter Property="Padding" Value="2"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Template" Value="{StaticResource Template.ComboBox.Editable}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value="0.7"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--ComboBoxButton Style-->
    <Style x:Key="DropDownToggleButton" 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="Background" Value="Transparent"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid x:Name="templateRoot" MinHeight="{TemplateBinding MinHeight}" SnapsToDevicePixels="True" Background="{TemplateBinding Background}"/>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background.Hover}"/>
                        </Trigger>

                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Background" TargetName="templateRoot" Value="{DynamicResource Element.Background.Pressed}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!--DropDownButton styles-->
    <ControlTemplate x:Key="Template.DropDownButton.Horizontal" TargetType="{x:Type c:DropDownButton}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
            </Grid.ColumnDefinitions>

            <Popup Grid.ColumnSpan="2" x:Name="PART_Popup" AllowsTransparency="True" Placement="Bottom"
                   IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">

                <Border x:Name="DropDownBorder" BorderBrush="{DynamicResource Element.Border}" BorderThickness="1" Background="{DynamicResource Element.Background}" Effect="{DynamicResource Shadow.Border}"
                        MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
                    <ScrollViewer x:Name="DropDownScrollViewer">
                        <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </ScrollViewer>
                </Border>
            </Popup>

            <ToggleButton Grid.Column="0" Grid.ColumnSpan="3" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                          Background="{TemplateBinding Background}" Style="{StaticResource DropDownToggleButton}" IsEnabled="{TemplateBinding IsEnabled}"
                          HorizontalContentAlignment="Right" VerticalContentAlignment="Center"/>

            <Border Grid.Column="0" Background="{TemplateBinding Icon}" VerticalAlignment="Center" HorizontalAlignment="Center" IsEnabled="{TemplateBinding IsEnabled}"
                    Margin="{TemplateBinding Padding}" Width="{TemplateBinding MaxSize}" Height="{TemplateBinding MaxSize}"/>

            <TextBlock Grid.Column="1" x:Name="TextBlockInternal" MaxWidth="{Binding Path=ActualWidth, RelativeSource={RelativeSource TemplatedParent}}" 
                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                       VerticalAlignment="Center" Text="{TemplateBinding Description}" TextWrapping="WrapWithOverflow" 
                       Effect="{TemplateBinding Effect}" IsHitTestVisible="False"/>

            <Path Grid.Column="2" Data="F1 M 0,1.7 L 3,5 L 6,1.7 L 6,0 L 3,3.2 L0,0 Z" Fill="{DynamicResource Element.Glyph}" VerticalAlignment="Center" Height="5" Width="6"/>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
            </Trigger>

            <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>

    <ControlTemplate x:Key="Template.DropDownButton.Vertical" TargetType="{x:Type c:DropDownButton}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Popup x:Name="PART_Popup" AllowsTransparency="True" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                   PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
                <Grid x:Name="shadow" Background="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
                    <Border x:Name="DropDownBorder" BorderBrush="{DynamicResource Element.Border}" BorderThickness="1" Background="{DynamicResource Element.Background}" Effect="{DynamicResource Shadow.Border}" Margin="0,0,0,5">
                        <ScrollViewer x:Name="DropDownScrollViewer">
                            <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
                                <Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
                                    <Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}"
                                               Width="{Binding ActualWidth, ElementName=DropDownBorder}"/>
                                </Canvas>

                                <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Grid>
                        </ScrollViewer>
                    </Border>
                </Grid>
            </Popup>

            <ToggleButton Grid.Row="0" Grid.RowSpan="3" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                          Background="{TemplateBinding Background}" Style="{StaticResource DropDownToggleButton}" IsEnabled="{TemplateBinding IsEnabled}"/>

            <Border Grid.Column="0" Background="{TemplateBinding Icon}" VerticalAlignment="Center" HorizontalAlignment="Center" IsEnabled="{TemplateBinding IsEnabled}"
                     Margin="{TemplateBinding Padding}" Width="{TemplateBinding MaxSize}" Height="{TemplateBinding MaxSize}"/>
            
            <TextBlock Grid.Row="1" x:Name="TextBlockInternal" MaxWidth="{Binding Path=ActualWidth, RelativeSource={RelativeSource TemplatedParent}}" 
                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" 
                       VerticalAlignment="Center" Text="{TemplateBinding Description}" TextWrapping="WrapWithOverflow" 
                       Effect="{TemplateBinding Effect}" IsHitTestVisible="False"/>

            <Path Grid.Row="2" Data="F1 M 0,1.7 L 3,5 L 6,1.7 L 6,0 L 3,3.2 L0,0 Z" Fill="{DynamicResource Element.Glyph}" VerticalAlignment="Center" HorizontalAlignment="Center" 
                  Height="5" Width="6" Margin="0,4"/>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
            </Trigger>

            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsGrouping" Value="True"/>
                    <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False"/>
                </MultiTrigger.Conditions>

                <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
            </MultiTrigger>

            <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="False">
                <Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
                <Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type c:DropDownButton}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource Style.FocusVisual.NoMargin}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="IsEditable" Value="False"/>
        <Setter Property="Foreground" Value="{DynamicResource Element.Foreground}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="Padding" Value="6,3,5,3"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
        <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Template" Value="{StaticResource Template.DropDownButton.Horizontal}"/>

        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value="0.7"/>
            </Trigger>
            <Trigger Property="IsVertical" Value="True">
                <Setter Property="Template" Value="{StaticResource Template.DropDownButton.Vertical}"/>
            </Trigger>
        </Style.Triggers>
    </Style>


    <v:StringToStaticResource x:Key="StringToStaticResource"/>
    
    <!--Common Templates-->
    <DataTemplate x:Key="Template.ComboBox.Simple">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="33"/>
                <ColumnDefinition Width="1"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <Border Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" x:Name="IconBorder" Background="{Binding ImageId, Converter={StaticResource StringToStaticResource}}"
                    Margin="1,1,4,1" Height="22" Width="30" VerticalAlignment="Center" HorizontalAlignment="Center"/>

            <Separator Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="1" Margin="0"/>
            <TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding Title}" Margin="10,0,2,0" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding Description}" Margin="10,0,2,0" Foreground="{DynamicResource Element.Foreground.Gray112}" 
                       TextTrimming="CharacterEllipsis" FontSize="11" VerticalAlignment="Center"/>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="Template.ComboBox.Item">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="1"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <TextBlock Grid.Column="0" Margin="1,1,5,1" Foreground="{DynamicResource Element.Foreground}" VerticalAlignment="Center">
                <TextBlock.Text>
                    <PriorityBinding>
                        <Binding Path="NameKey" Converter="{StaticResource StringToStaticResource}"/>
                        <Binding Path="Name"/>
                    </PriorityBinding>
                </TextBlock.Text>
            </TextBlock>

            <Separator Grid.Column="1" Width="1" Margin="0"/>
            
            <TextBlock Grid.Column="2" Margin="5,1,3,1" Foreground="{DynamicResource Element.Foreground.Gray112}" 
                       TextTrimming="CharacterEllipsis" FontSize="11" VerticalAlignment="Center">
                <TextBlock.Text>
                    <PriorityBinding>
                        <Binding Path="Parameter"/>
                        <Binding Path="Command"/>
                    </PriorityBinding>
                </TextBlock.Text>
            </TextBlock>
        </Grid>
    </DataTemplate>
</ResourceDictionary>