2020-06-02 03:35:37 +08:00
<UserControl
x:Class="PowerLauncher.ResultList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors"
2020-07-18 03:29:36 +08:00
mc:Ignorable="d"
2020-06-02 03:35:37 +08:00
d:DesignHeight="300"
d:DesignWidth="720">
<UserControl.Resources>
<ResourceDictionary>
2020-06-18 00:48:30 +08:00
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Styles/ModernScrollBarStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
2020-06-02 03:35:37 +08:00
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
2020-06-06 00:58:30 +08:00
<Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource ControlTextBrushKey}"/>
2020-06-02 03:35:37 +08:00
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="IconButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
2020-06-06 00:58:30 +08:00
<Setter Property="Foreground" Value="{DynamicResource ControlTextBrushKey}"/>
2020-06-02 03:35:37 +08:00
<Setter Property="BorderThickness" Value="1"/>
2020-07-18 03:29:36 +08:00
<Setter Property="Focusable" Value="False"/>
2020-06-02 03:35:37 +08:00
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" CornerRadius="4" Background="Transparent" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="Background" TargetName="border" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonBackgroundPointerOver}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonBorderPointerOver}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonBackgroundPressed}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonBorderPressed}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<!--<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ResultsListViewItemContainerStyle" TargetType="ListViewItem">
<Setter Property="Background" Value="Transparent" />
2020-06-06 00:58:30 +08:00
<Setter Property="Foreground" Value="{DynamicResource ControlTextBrushKey}" />
2020-06-02 03:35:37 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Grid Background="Transparent">
<Border x:Name="HighlightBorder" BorderThickness="0" Background="Transparent" BorderBrush="Transparent" SnapsToDevicePixels="true"/>
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<!-- Setting the opacity of the highlight border to improve the contrast of the AccentColorbrush when selected. In UWP we could call a different brush, in WPF we need to play with the opacity of the WindowGlassBrush-->
<Trigger Property="IsMouseOver" Value="True">
2020-06-11 02:15:15 +08:00
<Setter Property="Opacity" TargetName="HighlightBorder" Value="1" />
2020-06-02 03:35:37 +08:00
<Setter Property="Background" TargetName="HighlightBorder" Value="{DynamicResource ListViewItemBackgroundPointerOver}"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Opacity" TargetName="HighlightBorder" Value="0.4" />
<Setter Property="Background" TargetName="HighlightBorder" Value="{Binding Source={x:Static SystemParameters.WindowGlassBrush}}"/>
<!-- Accent color brush -->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
2020-07-18 03:29:36 +08:00
<Setter Property="Focusable" Value="False" />
2020-06-02 03:35:37 +08:00
</Style>
<Style x:Key="CommandButtonListViewItemContainerStyle" TargetType="ListViewItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border x:Name="border" CornerRadius="4" Background="Transparent" BorderBrush="Transparent" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonBackgroundPressed}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonBorderPressed}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2020-07-08 04:02:39 +08:00
<Style x:Key="CollapsableTextblock" TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
</Style.Triggers>
</Style>
2020-07-11 03:06:57 +08:00
<Style TargetType="{x:Type ToolTip}" >
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="HasDropShadow" Value="True" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Placement" Value="Bottom" />
<Setter Property="VerticalOffset" Value="0" />
<Setter Property="Padding" Value="8" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}" >
<StackPanel Margin="8,2" >
<Border CornerRadius="4" Background="{DynamicResource ToolTipBackgroundBrushKey}" BorderBrush="{DynamicResource ToolTipBorderBrushKey}" BorderThickness="1">
<ContentPresenter Margin="4" HorizontalAlignment="Center" VerticalAlignment="Top" />
</Border>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2020-06-02 03:35:37 +08:00
</ResourceDictionary>
</UserControl.Resources>
<Grid VerticalAlignment="Top">
<ListView
x:Name="SuggestionsList"
x:FieldModifier="public"
Background="Transparent"
BorderThickness="0"
MaxHeight="{Binding Results.MaxHeight}"
Margin="0"
ItemsSource="{Binding Results.Results, Mode=OneWay}"
Padding="0, 0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
2020-06-18 00:48:30 +08:00
ScrollViewer.VerticalScrollBarVisibility="Auto"
2020-06-02 03:35:37 +08:00
SelectionMode="Single"
SelectedIndex="{Binding Results.SelectedIndex, Mode=TwoWay}"
2020-08-06 04:43:47 +08:00
ItemContainerStyle="{StaticResource ResultsListViewItemContainerStyle}"
AutomationProperties.Name="{DynamicResource Results}">
2020-06-02 03:35:37 +08:00
<!--AllowFocusOnInteraction="False"
IsItemClickEnabled="True"-->
<!--Style="{StaticResource ListViewNoAnimations}"-->
<ListView.ItemTemplate>
2020-08-06 04:43:47 +08:00
<DataTemplate>
2020-07-08 04:02:39 +08:00
<Grid
Height="72"
Width="642"
Background="Transparent"
ToolTipService.BetweenShowDelay="0"
ToolTipService.InitialShowDelay="1000"
>
2020-06-02 03:35:37 +08:00
<Behaviors:Interaction.Triggers>
<Behaviors:EventTrigger EventName="MouseEnter">
<Behaviors:InvokeCommandAction Command="{Binding ActivateContextButtonsHoverCommand}"/>
</Behaviors:EventTrigger>
<Behaviors:EventTrigger EventName="MouseLeave">
<Behaviors:InvokeCommandAction Command="{Binding DeactivateContextButtonsHoverCommand}"/>
</Behaviors:EventTrigger>
</Behaviors:Interaction.Triggers>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="64" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions >
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
2020-07-08 04:02:39 +08:00
<Grid.ToolTip>
2020-07-11 03:06:57 +08:00
<ToolTip Visibility="{Binding Result.ToolTipVisibility}">
<StackPanel Margin="8,6">
2020-07-08 04:02:39 +08:00
<TextBlock
Style="{DynamicResource CollapsableTextblock}"
2020-07-11 03:06:57 +08:00
Foreground="{DynamicResource ToolTipForegroundBrushKey}" FontWeight="Bold" FontSize="12"
2020-07-08 04:02:39 +08:00
Text="{Binding Result.ToolTipData.Title}"
TextWrapping="Wrap" />
<TextBlock
Style="{DynamicResource CollapsableTextblock}"
2020-07-11 03:06:57 +08:00
Foreground="{DynamicResource ToolTipForegroundBrushKey}" FontSize="12"
2020-07-18 03:29:36 +08:00
Text="{Binding Result.ToolTipData.Text}"
2020-07-08 04:02:39 +08:00
TextWrapping="Wrap" />
</StackPanel>
</ToolTip>
</Grid.ToolTip>
2020-08-06 04:43:47 +08:00
<Image AutomationProperties.Name="{DynamicResource AppIcon}" x:Name="AppIcon" Height="36" MaxWidth="56" Grid.RowSpan="2" Margin="-6,-2,0,0" HorizontalAlignment="Center" Source="{Binding Image}" />
<TextBlock AutomationProperties.Name="{DynamicResource Title}" x:Name="Title" Grid.Column="1" Text="{Binding Result.Title}" FontWeight="SemiBold" FontSize="20" Margin="0,0,0,-2" VerticalAlignment="Bottom"/>
<TextBlock AutomationProperties.Name="{DynamicResource Subtitle}" x:Name="Path" Grid.Column="1" Text= "{Binding Result.SubTitle}" Grid.Row="1" Foreground="{DynamicResource SecondaryTextForeground}" Margin="0,2,0,0" VerticalAlignment="Top"/>
<ListView
AutomationProperties.Name="{DynamicResource ContextMenuItemsCollection}"
2020-06-02 03:35:37 +08:00
HorizontalAlignment="Right"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
Grid.RowSpan="2"
Grid.Column="2"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding ContextMenuItems}"
SelectionMode="Single"
2020-06-27 07:12:26 +08:00
Margin="0,0,-8,0"
2020-06-02 03:35:37 +08:00
SelectedIndex="{Binding ContextMenuSelectedIndex}"
Visibility="{Binding AreContextButtonsActive, Converter={StaticResource BooleanToVisibilityConverter}}"
ItemContainerStyle="{StaticResource CommandButtonListViewItemContainerStyle}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
2020-08-06 04:43:47 +08:00
<Button AutomationProperties.Name="{DynamicResource ContextMenuItem}" Style="{StaticResource IconButtonStyle}" Command="{Binding Command}" VerticalAlignment="Center" Height="42" Width="42" BorderThickness="1" >
2020-06-02 03:35:37 +08:00
<ToolTipService.ToolTip>
2020-07-11 03:06:57 +08:00
<ToolTip >
2020-08-06 04:43:47 +08:00
<TextBlock AutomationProperties.Name="{DynamicResource ContextMenuItemAdditionalInformation}" Text="{Binding Title}" Foreground="{DynamicResource ToolTipForegroundBrushKey}" Margin="8,5" FontSize="12"/>
2020-07-11 03:06:57 +08:00
</ToolTip>
2020-06-02 03:35:37 +08:00
</ToolTipService.ToolTip>
<Button.Content>
2020-08-06 04:43:47 +08:00
<TextBlock AutomationProperties.Name="{DynamicResource ContextMenuIcon}" FontFamily="{Binding FontFamily}" FontSize="16" Text="{Binding Glyph}"/>
2020-06-02 03:35:37 +08:00
</Button.Content>
</Button>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</UserControl>