2014-01-29 18:33:24 +08:00
|
|
|
<UserControl x:Class="Wox.ResultPanel"
|
2015-07-13 03:13:30 +08:00
|
|
|
x:Name="Results"
|
2013-12-22 19:35:21 +08:00
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
2014-01-26 17:47:58 +08:00
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
2014-05-24 16:07:03 +08:00
|
|
|
xmlns:converters="clr-namespace:Wox.Converters"
|
|
|
|
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
|
2014-02-19 22:50:15 +08:00
|
|
|
|
2016-01-02 12:34:20 +08:00
|
|
|
<ListBox x:Name="lbResults" MaxHeight="{Binding ElementName=Results, Path=MaxResultsToShow}"
|
|
|
|
HorizontalContentAlignment="Stretch" PreviewMouseDown="LbResults_OnPreviewMouseDown"
|
|
|
|
Style="{DynamicResource BaseListboxStyle}" SelectionChanged="lbResults_SelectionChanged" Focusable="False"
|
|
|
|
KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single"
|
|
|
|
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard">
|
2014-03-20 21:41:30 +08:00
|
|
|
<ListBox.ItemTemplate>
|
|
|
|
<DataTemplate>
|
|
|
|
<!-- a result item height is 50 including margin -->
|
2016-01-02 12:34:20 +08:00
|
|
|
<Grid HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Stretch" Margin="5"
|
|
|
|
Cursor="Hand">
|
2014-07-16 18:52:00 +08:00
|
|
|
<Grid.Resources>
|
|
|
|
<converters:ImagePathConverter x:Key="ImageConverter" />
|
|
|
|
</Grid.Resources>
|
2014-03-20 21:41:30 +08:00
|
|
|
<Grid.ColumnDefinitions>
|
2016-01-02 12:34:20 +08:00
|
|
|
<ColumnDefinition Width="32" />
|
|
|
|
<ColumnDefinition />
|
2015-02-09 19:16:13 +08:00
|
|
|
<ColumnDefinition Width="0" />
|
2014-03-20 21:41:30 +08:00
|
|
|
</Grid.ColumnDefinitions>
|
2016-01-02 12:34:20 +08:00
|
|
|
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left"
|
|
|
|
Source="{Binding FullIcoPath,Converter={StaticResource ImageConverter},IsAsync=True}" />
|
2014-03-20 21:41:30 +08:00
|
|
|
<Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch">
|
|
|
|
<Grid.RowDefinitions>
|
2016-01-02 12:34:20 +08:00
|
|
|
<RowDefinition />
|
|
|
|
<RowDefinition Height="Auto" x:Name="SubTitleRowDefinition" />
|
2014-03-20 21:41:30 +08:00
|
|
|
</Grid.RowDefinitions>
|
2016-01-02 12:34:20 +08:00
|
|
|
<TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left"
|
|
|
|
VerticalAlignment="Center" ToolTip="{Binding Title}" x:Name="tbTitle"
|
|
|
|
Text="{Binding Title}" />
|
|
|
|
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding SubTitle}"
|
|
|
|
Visibility="{Binding SubTitle, Converter={converters:StringNullOrEmptyToVisibilityConverter}}"
|
|
|
|
Grid.Row="1" x:Name="tbSubTitle" Text="{Binding SubTitle}" />
|
2014-02-19 22:50:15 +08:00
|
|
|
</Grid>
|
2016-01-02 12:34:20 +08:00
|
|
|
<TextBlock Grid.Column="2" x:Name="tbItemNumber" Style="{DynamicResource ItemNumberStyle}" Text="9"/>
|
2014-03-20 21:41:30 +08:00
|
|
|
</Grid>
|
|
|
|
<DataTemplate.Triggers>
|
2016-01-02 12:34:20 +08:00
|
|
|
<DataTrigger
|
|
|
|
Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
|
|
|
|
Value="True">
|
|
|
|
<Setter TargetName="tbTitle" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" />
|
|
|
|
<Setter TargetName="tbSubTitle" Property="Style"
|
|
|
|
Value="{DynamicResource ItemSubTitleSelectedStyle}" />
|
2014-03-20 21:41:30 +08:00
|
|
|
</DataTrigger>
|
|
|
|
</DataTemplate.Triggers>
|
|
|
|
</DataTemplate>
|
|
|
|
</ListBox.ItemTemplate>
|
2016-01-02 12:34:20 +08:00
|
|
|
<!--http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062-->
|
|
|
|
<ListBox.ItemContainerStyle>
|
|
|
|
<Style TargetType="{x:Type ListBoxItem}">
|
|
|
|
<Setter Property="Template">
|
|
|
|
<Setter.Value>
|
|
|
|
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
|
|
|
<Border x:Name="Bd"
|
|
|
|
Background="{TemplateBinding Background}"
|
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
|
|
Padding="{TemplateBinding Padding}"
|
|
|
|
SnapsToDevicePixels="True">
|
|
|
|
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
|
|
Content="{TemplateBinding Content}"
|
|
|
|
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
|
|
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
|
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
|
|
</Border>
|
|
|
|
<ControlTemplate.Triggers>
|
|
|
|
<Trigger Property="IsSelected" Value="True">
|
|
|
|
<Setter TargetName="Bd" Property="Background"
|
|
|
|
Value="{DynamicResource ItemSelectedBackgroundColor}" />
|
|
|
|
<Setter TargetName="Bd" Property="BorderBrush"
|
|
|
|
Value="{DynamicResource ItemSelectedBackgroundColor}" />
|
|
|
|
</Trigger>
|
|
|
|
</ControlTemplate.Triggers>
|
|
|
|
</ControlTemplate>
|
|
|
|
</Setter.Value>
|
|
|
|
</Setter>
|
|
|
|
</Style>
|
|
|
|
</ListBox.ItemContainerStyle>
|
2014-03-20 21:41:30 +08:00
|
|
|
</ListBox>
|
2014-01-26 17:47:58 +08:00
|
|
|
</UserControl>
|