<UserControl
    x:Class="NuGet.WebMatrix.SearchPageHeader"
    x:ClassModifier="internal"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    mc:Ignorable="d"
    d:DesignHeight="80"
    d:DesignWidth="300"
    xmlns:assembly="clr-namespace:NuGet.WebMatrix"
    x:Name="_searchPageHeader">
    <UserControl.Resources>
        <Style
            x:Key="NoBorderButton"
            TargetType="{x:Type Button}">
            <Setter
                Property="Template">
                <Setter.Value>
                    <ControlTemplate
                        TargetType="{x:Type Button}">
                        <Grid
                            x:Name="LayoutRoot">
                            <ContentPresenter
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                Margin="{TemplateBinding Padding}"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <DockPanel
        LastChildFill="True">
        <StackPanel x:Name="_searchStackPanel"
                    Orientation="Horizontal"
                    DockPanel.Dock="Right">
            <StackPanel.Style>
                <Style TargetType="{x:Type StackPanel}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=IsLicensePageVisible, Mode=OneWay}"
                                     Value="True">
                            <Setter Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=IsUninstallPageVisible, Mode=OneWay}"
                                     Value="True">
                            <Setter Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=IsDetailsPaneVisible, Mode=OneWay}"
                                     Value="True">
                            <Setter Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=Loading, Mode=OneWay}"
                                     Value="True">
                            <Setter Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
            <TextBox
                x:Name="_searchTextBox"
                     Text="{Binding ElementName=_searchPageHeader, Path=SearchString, UpdateSourceTrigger=PropertyChanged}"
                Width="200"
                Tag="{x:Static assembly:Resources.String_EnterSearchString}"
                Height="22" />

            <Button
                x:Name="_searchButton"
                Click="SearchButton_Click"
                VerticalAlignment="Center"
                ToolTip="{x:Static assembly:Resources.String_ClearSearchResults}"
                Style="{DynamicResource NoBorderButton}"
                Padding="0"
                Width="22"
                Height="22">
                <Image
                    Name="_buttonImage"
                    Height="16"
                    Width="16" />
            </Button>
        </StackPanel>

        <ContentControl
            x:Name="_headerTextBlockContentControl"
            Focusable="False" />
    </DockPanel>
</UserControl>
