<UserControl x:Class="AvalonStudio.Studio.QuickCommander"
             xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:control="clr-namespace:AvalonStudio.Studio;assembly=AvalonStudio.Studio"
             xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
             xmlns:iac="clr-namespace:Avalonia.Xaml.Interactions.Custom;assembly=Avalonia.Xaml.Interactions.Custom"
             xmlns:beh="clr-namespace:AvalonStudio.Shell.Behaviors;assembly=AvalonStudio.Shell" 
             Name="PART_QuickCommander" 
             IsVisible="{Binding IsVisible, Mode=TwoWay}">
    <UserControl.Styles>
        <Style Selector="ListBoxItem:selected /template/ ContentPresenter">
            <Setter Property="Background" Value="{DynamicResource ThemeControlDarkBrush}" />
        </Style>
        <Style Selector="ListBoxItem:selected">
            <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
        </Style>
    </UserControl.Styles>
    <UserControl.KeyBindings>
        <KeyBinding Command="{Binding UpCommand}" Gesture="Up"/>
        <KeyBinding Command="{Binding DownCommand}" Gesture="Down"/>
        <KeyBinding Command="{Binding EscapeCommand}" Gesture="Escape"/>
        <KeyBinding Command="{Binding EnterCommand}" Gesture="Enter"/>
    </UserControl.KeyBindings>
    <i:Interaction.Behaviors>
        <beh:HideOnLostFocusBehavior />
    </i:Interaction.Behaviors>
    <DockPanel LastChildFill="True">
        <TextBox Watermark="Quick Find" UseFloatingWatermark="true" Text="{Binding CommandQuery}" Name="PART_CommandBox" DockPanel.Dock="Top" BorderThickness="1">
            <i:Interaction.Behaviors>
                <beh:FocusOnVisibleBehavior AttachedControlName="PART_QuickCommander" />
                <iac:FocusOnAttachedToVisualTreeBehavior />
            </i:Interaction.Behaviors>
        </TextBox>
        <ListBox Items="{Binding Results}" IsVisible="{Binding ResultsVisible}" Margin="0 -1 0 0" 
                     Background="{DynamicResource ThemeBackgroundBrush}" 
                     SelectedItem="{Binding SelectedResult, Mode=TwoWay}" 
                     SelectedIndex="{Binding SelectedIndex}"  
                     MaxHeight="450" BorderThickness="1" BorderBrush="{DynamicResource ThemeBorderDarkBrush}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <control:SearchResult />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </DockPanel>
</UserControl>