Fix a UI issue.

This commit is contained in:
qianlifeng
2014-03-20 21:41:30 +08:00
parent b3f3cd2ffd
commit 3b2e54a156
4 changed files with 49 additions and 57 deletions

View File

@@ -13,15 +13,10 @@
Icon="Images\app.png" Icon="Images\app.png"
> >
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown"> <Border Style="{DynamicResource WindowBorderStyle}" MouseDown="Border_OnMouseDown">
<Grid x:Name="grid" > <StackPanel Orientation="Vertical">
<Grid.RowDefinitions>
<RowDefinition ></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" /> <TextBox Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />
<Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line> <Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line>
<wox:ResultPanel x:Name="resultCtrl" Grid.Row="2"/> <wox:ResultPanel x:Name="resultCtrl" Grid.Row="2"/>
</Grid> </StackPanel>
</Border> </Border>
</Window> </Window>

View File

@@ -4,56 +4,54 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wox="clr-namespace:Wox" xmlns:wox="clr-namespace:Wox"
mc:Ignorable="d" mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"
d:DesignHeight="300" d:DesignWidth="300"> >
<UserControl.Resources> <UserControl.Resources>
<wox:ImagePathConverter x:Key="ImagePathConverter"/> <wox:ImagePathConverter x:Key="ImagePathConverter"/>
</UserControl.Resources> </UserControl.Resources>
<Grid x:Name="gridContainer"> <!-- set max height of listbox to allow 6 results showed at once -->
<!-- set max height of listbox to allow 6 results showed at once --> <ListBox x:Name="lbResults" MaxHeight="300" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
<ListBox x:Name="lbResults" MaxHeight="300" PreviewMouseDown="LbResults_OnPreviewMouseDown" Style="{DynamicResource BaseListboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard"> <ListBox.Resources>
<ListBox.Resources> <!--SelectedItem with focus-->
<!--SelectedItem with focus--> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/> <!--SelectedItem without focus-->
<!--SelectedItem without focus--> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource ItemSelectedBackgroundColor}"/> </ListBox.Resources>
</ListBox.Resources> <ListBox.ItemTemplate>
<ListBox.ItemTemplate> <DataTemplate>
<DataTemplate> <!-- a result item height is 50 including margin -->
<!-- a result item height is 50 including margin --> <Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5" Cursor="Hand">
<Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5" Cursor="Hand"> <Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> <ColumnDefinition Width="32"></ColumnDefinition>
<ColumnDefinition Width="32"></ColumnDefinition> <ColumnDefinition/>
<ColumnDefinition/> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" >
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" > <Image.Source>
<Image.Source> <MultiBinding Converter="{StaticResource ImagePathConverter}">
<MultiBinding Converter="{StaticResource ImagePathConverter}"> <MultiBinding.Bindings>
<MultiBinding.Bindings> <Binding Path="IcoPath" />
<Binding Path="IcoPath" /> <Binding Path="PluginDirectory" />
<Binding Path="PluginDirectory" /> </MultiBinding.Bindings>
</MultiBinding.Bindings> </MultiBinding>
</MultiBinding> </Image.Source>
</Image.Source> </Image>
</Image> <Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch">
<Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch"> <Grid.RowDefinitions>
<Grid.RowDefinitions> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition Height="Auto" x:Name="SubTitleRowDefinition"></RowDefinition>
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition"></RowDefinition> </Grid.RowDefinitions>
</Grid.RowDefinitions> <TextBlock Style="{DynamicResource ItemTitleStyle}" VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle" Text="{Binding Title}"></TextBlock>
<TextBlock Style="{DynamicResource ItemTitleStyle}" VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle" Text="{Binding Title}"></TextBlock> <TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding SubTitle}" Visibility="{Binding SubTitle, Converter={wox:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}"></TextBlock>
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding SubTitle}" Visibility="{Binding SubTitle, Converter={wox:StringNullOrEmptyToVisibilityConverter}}" Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}"></TextBlock>
</Grid>
</Grid> </Grid>
<DataTemplate.Triggers> </Grid>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True"> <DataTemplate.Triggers>
<Setter TargetName="tbTitle" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}"/> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
<Setter TargetName="tbSubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}"/> <Setter TargetName="tbTitle" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}"/>
</DataTrigger> <Setter TargetName="tbSubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}"/>
</DataTemplate.Triggers> </DataTrigger>
</DataTemplate> </DataTemplate.Triggers>
</ListBox.ItemTemplate> </DataTemplate>
</ListBox> </ListBox.ItemTemplate>
</Grid> </ListBox>
</UserControl> </UserControl>

View File

@@ -39,7 +39,7 @@ namespace Wox
int position = GetInsertLocation(result.Score); int position = GetInsertLocation(result.Score);
lbResults.Items.Insert(position, result); lbResults.Items.Insert(position, result);
} }
gridContainer.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 }; lbResults.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 };
SelectFirst(); SelectFirst();
} }
@@ -150,7 +150,7 @@ namespace Wox
public void Clear() public void Clear()
{ {
lbResults.Items.Clear(); lbResults.Items.Clear();
gridContainer.Margin = new Thickness { Top = 0 }; lbResults.Margin = new Thickness { Top = 0 };
} }
private void lbResults_SelectionChanged(object sender, SelectionChangedEventArgs e) private void lbResults_SelectionChanged(object sender, SelectionChangedEventArgs e)

View File

@@ -20,7 +20,6 @@
<Setter Property="Padding" Value="8 10 8 8" /> <Setter Property="Padding" Value="8 10 8 8" />
</Style> </Style>
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}"> <Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
<Setter Property="Height" Value="80" />
<Setter Property="Width" Value="500" /> <Setter Property="Width" Value="500" />
</Style> </Style>