<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI"
                    xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0">

    <Style TargetType="{x:Type ui:FilterTextBox}">
        <Setter Property="Background" Value="{DynamicResource {x:Static vs:CommonControlsColors.TextBoxBackgroundBrushKey}}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource {x:Static vs:CommonControlsColors.TextBoxBorderBrushKey}}"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static vs:CommonControlsColors.TextBoxTextBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
        <Setter Property="Padding" Value="3,3,18,3" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ui:FilterTextBox}">
                    <Grid>
                        <Border
                            x:Name="Bd"
                            CornerRadius="2"
                            ClipToBounds="True"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="True">
                            <Border
                                CornerRadius="0"
                                BorderBrush="Black"
                                BorderThickness="0,1,0,0"
                                Margin="2,-2,2,0"
                                Opacity="0.4">
                                <Border.Effect>
                                    <DropShadowEffect Direction="270" ShadowDepth="0" BlurRadius="4" Opacity="1" />
                                </Border.Effect>
                            </Border>
                        </Border>

                        <Grid Margin="1,1,0,0">
                            <ScrollViewer
                                x:Name="PART_ContentHost"
                                Padding="{TemplateBinding Padding}"
                                Focusable="false"
                                HorizontalScrollBarVisibility="Hidden"
                                VerticalScrollBarVisibility="Hidden"
                                VerticalAlignment="Top"
                                Margin="0"/>
                            <Label x:Name="PromptLabel"
                                 FontSize="{TemplateBinding FontSize}" 
                                 Foreground="{TemplateBinding Foreground}"
                                 Margin="2,0,0,0" 
                                 Padding="{TemplateBinding Padding}"
                                 Opacity="0"
                                 Target="{Binding ElementName=Bd}"
                                 SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                 Focusable="False" 
                                 IsHitTestVisible="False"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Top">
                                <TextBlock 
                                    Text="{TemplateBinding PromptText}" 
                                    Opacity="0.5"
                                    TextTrimming="CharacterEllipsis" />
                            </Label>
                        </Grid>

                        <Button
                            x:Name="clearButton"
                            Focusable="False"
                            HorizontalAlignment="Right"
                            Margin="0,0,3,0"
                            Foreground="{TemplateBinding Foreground}">
                            <Button.Style>
                                <Style TargetType="{x:Type Button}">
                                    <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                                    <Setter Property="Opacity" Value="0.7"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type Button}">
                                                <Grid Background="Transparent">
                                                    <Path 
                                                        SnapsToDevicePixels="True" 
                                                        Height="16" 
                                                        Width="16" 
                                                        Data="m 12.5,5 -3,3 3,3 -1.5,1.5 -3,-3 -3,3 L 3.5,11 6.5,8 3.5,5 5,3.5 l 3,3 3,-3 z" 
                                                        Fill="{TemplateBinding Foreground}" />
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>

                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Opacity" Value="1" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Button.Style>
                        </Button>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsEnabled" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource {x:Static vs:CommonControlsColors.TextBoxBorderFocusedBrushKey}}" />
                                <Setter Property="Opacity" TargetName="clearButton" Value="1" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource {x:Static vs:CommonControlsColors.TextBoxBorderFocusedBrushKey}}" />
                        </Trigger>
                        <DataTrigger Binding="{Binding Text.Length, RelativeSource={RelativeSource Self}}" Value="0">
                            <Setter Property="Opacity" TargetName="PromptLabel" Value="0.7" />
                            <Setter Property="Visibility" TargetName="clearButton" Value="Collapsed" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>