<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:bpa="clr-namespace:BPA.UIControl"
                    xmlns:converter="clr-namespace:BPA.UIControl.Converters">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Textbox.xaml" />
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/ScrollViewer.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <converter:ComboBoxPopupWidthConverter x:Key="ComboBoxPopupWidth" />

    <Style x:Key="RubyerComboBoxItem" TargetType="{x:Type ComboBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Padding" Value="{Binding Path=(bpa:ItemsControlHelper.ItemPadding), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
        <Setter Property="Margin" Value="{Binding Path=(bpa:ItemsControlHelper.ItemMargin), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid>
                        <bpa:ControlMask x:Name="mask"
                                         Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=ItemsControl}}"
                                         CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=ItemsControl}}"
                                         IsActive="{TemplateBinding IsSelected}"
                                         MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource AncestorType=ItemsControl}}" />
                        <Border x:Name="Bd"
                                Padding="{TemplateBinding Padding}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <DockPanel>
                                <CheckBox x:Name="selectCheckBox"
                                          Margin="0 0 5 0"
                                          IsChecked="{Binding Path=(bpa:ComboBoxHelper.IsSelected), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                          Visibility="Collapsed" />
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </DockPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Bd" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                        <DataTrigger Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource AncestorType=ComboBox}}" Value="True">
                            <Setter TargetName="selectCheckBox" Property="Visibility" Value="Visible" />
                            <Setter TargetName="mask" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RubyerComboBoxEditableTextBox"
           BasedOn="{StaticResource RubyerTextBox}"
           TargetType="{x:Type TextBox}">
        <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="BorderThickness" Value="0" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
    </Style>

    <Style x:Key="RubyerComboBoxToggleButton" 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="{DynamicResource DefaultBackground}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <Border x:Name="effectBorder"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}"
                                BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource AncestorType=ComboBox}}"
                                CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=ComboBox}}"
                                Opacity="0">
                            <Border.Effect>
                                <DropShadowEffect x:Name="shadowEffect"
                                                  BlurRadius="2"
                                                  Direction="0"
                                                  ShadowDepth="0"
                                                  Color="{Binding BorderBrush.Color, ElementName=effectBorder}" />
                            </Border.Effect>
                        </Border>
                        <Border x:Name="templateRoot"
                                Padding="{TemplateBinding Margin}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <DockPanel>
                                <bpa:Icon x:Name="arrow"
                                          Grid.Column="1"
                                          Margin="0 0 3 0"
                                          VerticalAlignment="Center"
                                          DockPanel.Dock="Right"
                                          Foreground="{DynamicResource SeconarydText}"
                                          RenderTransformOrigin="0.5,0.5"
                                          Type="ArrowDownSLine">
                                    <bpa:Icon.RenderTransform>
                                        <RotateTransform x:Name="arrowTransform" Angle="0" />
                                    </bpa:Icon.RenderTransform>
                                </bpa:Icon>

                                <ContentPresenter Focusable="False" SnapsToDevicePixels="True" />
                            </DockPanel>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <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" />
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                        </MultiDataTrigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="arrow" Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                        <DataTrigger Binding="{Binding Path=(bpa:ControlHelper.IsKeyBoardFocused), RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="True">
                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
                            <DataTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="effectBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To="1"
                                                         Duration="0:0:0.25" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </DataTrigger.EnterActions>
                            <DataTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="effectBorder"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0:0:0.25" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </DataTrigger.ExitActions>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource Mode=Self}}" Value="True">
                            <Setter TargetName="arrow" Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource AncestorType=ComboBox}}" />
                            <DataTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="arrowTransform"
                                                         Storyboard.TargetProperty="Angle"
                                                         To="180"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <CubicEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </DataTrigger.EnterActions>
                            <DataTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="arrowTransform"
                                                         Storyboard.TargetProperty="Angle"
                                                         To="0"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <CubicEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </DataTrigger.ExitActions>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="RubyerComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Popup x:Name="PART_Popup"
                   Grid.ColumnSpan="2"
                   MaxHeight="{TemplateBinding MaxDropDownHeight}"
                   AllowsTransparency="True"
                   HorizontalOffset="-5"
                   IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                   Placement="Bottom"
                   PopupAnimation="Fade">
                <Popup.MinWidth>
                    <MultiBinding Converter="{StaticResource ComboBoxPopupWidth}">
                        <Binding ElementName="templateRoot" Path="ActualWidth" />
                        <Binding ElementName="dropDownBorder" Path="Margin.Left" />
                    </MultiBinding>
                </Popup.MinWidth>
                <Grid>
                    <Border x:Name="dropDownBorder"
                            Margin="5"
                            Background="{DynamicResource FloatBackground}"
                            CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                            Effect="{DynamicResource AllDirectionEffect}" />
                    <ScrollViewer x:Name="DropDownScrollViewer"
                                  Style="{StaticResource SmallScrollViewer}"
                                  Margin="5 10">
                        <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
                            <ItemsPresenter x:Name="ItemsPresenter"
                                            KeyboardNavigation.DirectionalNavigation="Contained"
                                            OverridesDefaultStyle="True"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Grid>
                    </ScrollViewer>
                </Grid>
            </Popup>

            <ToggleButton x:Name="toggleButton"
                          Style="{StaticResource RubyerComboBoxToggleButton}"
                          Grid.ColumnSpan="3"
                          Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="{TemplateBinding BorderThickness}"
                          IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
                <Grid SnapsToDevicePixels="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <TextBox x:Name="PART_EditableTextBox"
                             Style="{StaticResource RubyerComboBoxEditableTextBox}"
                             Margin="{TemplateBinding Padding}"
                             Padding="0"
                             HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                             VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                             bpa:InputBoxHelper.InternalSpacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                             bpa:InputBoxHelper.PostContent="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                             bpa:InputBoxHelper.PreContent="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                             bpa:InputBoxHelper.Watermark="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                             IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" />

                    <Button x:Name="clearButton"
                            Style="{StaticResource TextButton}"
                            Grid.Column="1"
                            Padding="2"
                            bpa:ButtonHelper.Shape="Circle"
                            Foreground="{DynamicResource SeconarydText}"
                            Visibility="Collapsed">
                        <bpa:Icon Type="CloseLine" />
                    </Button>
                </Grid>
            </ToggleButton>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="PART_EditableTextBox" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
            </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>
            <Trigger SourceName="toggleButton" Property="IsChecked" Value="True">
                <Setter TargetName="toggleButton" Property="IsHitTestVisible" Value="False" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
                    <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="RubyerComboBox" TargetType="{x:Type ComboBox}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="DeepSkyBlue" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Padding" Value="0 5" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="MaxDropDownHeight" Value="400" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource RubyerComboBoxItem}" />
        <Setter Property="Validation.ErrorTemplate" Value="{StaticResource RubyerValidationErrorTemplate}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Self}}" />
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
        <Setter Property="bpa:ControlHelper.MaskOpacity" Value="0.4" />
        <Setter Property="bpa:ControlHelper.IsKeyBoardFocused" Value="False" />
        <Setter Property="bpa:ItemsControlHelper.ItemMargin" Value="5 0.5" />
        <Setter Property="bpa:ItemsControlHelper.ItemPadding" Value="5" />
        <Setter Property="bpa:ItemsControlHelper.EnumValuesToItemsSource" Value="False" />
        <Setter Property="bpa:ComboBoxHelper.IsMultiSelect" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Grid x:Name="templateRoot"
                          Background="Transparent"
                          SnapsToDevicePixels="True">

                        <Popup x:Name="PART_Popup"
                               Grid.ColumnSpan="2"
                               MaxHeight="{TemplateBinding MaxDropDownHeight}"
                               AllowsTransparency="True"
                               HorizontalOffset="-5"
                               IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                               Placement="Bottom"
                               PopupAnimation="Fade">
                            <Popup.MinWidth>
                                <MultiBinding Converter="{StaticResource ComboBoxPopupWidth}">
                                    <Binding ElementName="templateRoot" Path="ActualWidth" />
                                    <Binding ElementName="dropDownBorder" Path="Margin.Left" />
                                </MultiBinding>
                            </Popup.MinWidth>
                            <Grid>
                                <Border x:Name="dropDownBorder"
                                        Margin="5"
                                        Background="{DynamicResource FloatBackground}"
                                        CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                        Effect="{DynamicResource AllDirectionEffect}" />
                                <ScrollViewer x:Name="DropDownScrollViewer"
                                              Style="{StaticResource SmallScrollViewer}"
                                              Margin="5 10">
                                    <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
                                        <ItemsPresenter x:Name="ItemsPresenter"
                                                        KeyboardNavigation.DirectionalNavigation="Contained"
                                                        OverridesDefaultStyle="True"
                                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                    </Grid>
                                </ScrollViewer>
                            </Grid>
                        </Popup>

                        <ToggleButton x:Name="toggleButton"
                                      Style="{StaticResource RubyerComboBoxToggleButton}"
                                      Grid.ColumnSpan="2"
                                      Background="{TemplateBinding Background}"
                                      BorderBrush="{TemplateBinding BorderBrush}"
                                      BorderThickness="{TemplateBinding BorderThickness}"
                                      IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
                            <Grid Margin="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), Converter={StaticResource DoubleToLeftAndRightThicknessConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                  bpa:GridHelper.ColumnDefinitions="Auto,*,Auto,Auto"
                                  bpa:PanelHelper.Spacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}">

                                <ContentControl x:Name="preContent"
                                                Grid.Column="0"
                                                VerticalAlignment="Center"
                                                Content="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                Foreground="{DynamicResource SeconarydText}"
                                                IsHitTestVisible="False"
                                                IsTabStop="False" />

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

                                    <TextBlock x:Name="multiSelectText"
                                               Margin="{TemplateBinding Padding}"
                                               VerticalAlignment="Center"
                                               IsHitTestVisible="False"
                                               Text="{Binding Path=(bpa:ComboBoxHelper.MultiSelectText), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                               Visibility="Collapsed" />

                                    <TextBlock x:Name="watermark"
                                               VerticalAlignment="Center"
                                               Foreground="{DynamicResource WatermarkText}"
                                               IsHitTestVisible="False"
                                               Text="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                                </Grid>

                                <Button x:Name="clearButton"
                                        Style="{StaticResource TextButton}"
                                        Grid.Column="2"
                                        Padding="2"
                                        bpa:ButtonHelper.Shape="Circle"
                                        Focusable="False"
                                        Foreground="{DynamicResource SeconarydText}"
                                        Visibility="Collapsed">
                                    <bpa:Icon Type="CloseLine" />
                                </Button>

                                <ContentControl x:Name="postContent"
                                                Grid.Column="3"
                                                VerticalAlignment="Center"
                                                Content="{Binding Path=(bpa:InputBoxHelper.PostContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                Foreground="{DynamicResource SeconarydText}"
                                                IsHitTestVisible="False"
                                                IsTabStop="False" />
                            </Grid>
                        </ToggleButton>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                        <Trigger Property="HasItems" Value="False">
                            <Setter TargetName="dropDownBorder" Property="Height" Value="100" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsGrouping" Value="True" />
                                <Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
                                <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
                            </MultiTrigger.Conditions>
                            <!--<Setter TargetName="clearButton" Property="Visibility" Value="Visible" />-->
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="bpa:InputBoxHelper.IsClearable" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
                        </MultiTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="False" />
                                <Condition Binding="{Binding Path=Content, ElementName=contentPresenter, Converter={StaticResource IsNullOrEmptyConverter}}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="watermark" Property="Visibility" Value="Hidden" />
                        </MultiDataTrigger>
                        <Trigger Property="bpa:InputBoxHelper.IsRound" Value="True">
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=Text, ElementName=multiSelectText, Converter={StaticResource IsNullOrEmptyConverter}}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="watermark" Property="Visibility" Value="Hidden" />
                        </MultiDataTrigger>
                        <DataTrigger Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="multiSelectText" Property="Visibility" Value="Visible" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource Self}}" Value="True" />
                    <Condition Binding="{Binding Path=(bpa:ComboBoxHelper.IsMultiSelect), RelativeSource={RelativeSource Self}}" Value="False" />
                </MultiDataTrigger.Conditions>
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Template" Value="{StaticResource RubyerComboBoxEditableTemplate}" />
            </MultiDataTrigger>
            <Trigger Property="IsKeyboardFocused" Value="True">
                <Setter Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="bpa:ControlHelper.IsKeyBoardFocused" Value="True" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  Filled ComboBox  -->
    <Style x:Key="FilledComboBox"
           BasedOn="{StaticResource RubyerComboBox}"
           TargetType="{x:Type ComboBox}">
        <Setter Property="BorderBrush" Value="{DynamicResource BorderLighter}" />
        <Setter Property="Background" Value="{DynamicResource BorderLighter}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Border}" />
    </Style>
</ResourceDictionary>