mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Added query submitted event to handle default action on clicking a list view item
This commit is contained in:
@@ -422,7 +422,7 @@
|
|||||||
<SymbolIcon Symbol="Find"/>
|
<SymbolIcon Symbol="Find"/>
|
||||||
</AutoSuggestBox.QueryIcon>
|
</AutoSuggestBox.QueryIcon>
|
||||||
<AutoSuggestBox.ItemTemplate>
|
<AutoSuggestBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate >
|
||||||
<Grid Height="72" Width="690" Background="Transparent" RowSpacing="0">
|
<Grid Height="72" Width="690" Background="Transparent" RowSpacing="0">
|
||||||
<Interactivity:Interaction.Behaviors>
|
<Interactivity:Interaction.Behaviors>
|
||||||
<Core:EventTriggerBehavior EventName="PointerEntered">
|
<Core:EventTriggerBehavior EventName="PointerEntered">
|
||||||
@@ -442,7 +442,7 @@
|
|||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Image x:Name="AppIcon" Height="36" Margin="8,0,0,0" Grid.RowSpan="2" HorizontalAlignment="Left" />
|
<Image x:Name="AppIcon" Height="36" Margin="8,0,0,0" Grid.RowSpan="2" HorizontalAlignment="Left" Source="{Binding Result.IcoPath}" />
|
||||||
<TextBlock x:Name="Title" Grid.Column="1" Text="{Binding Result.Title}" FontWeight="SemiBold" FontSize="20" VerticalAlignment="Bottom"/>
|
<TextBlock x:Name="Title" Grid.Column="1" Text="{Binding Result.Title}" FontWeight="SemiBold" FontSize="20" VerticalAlignment="Bottom"/>
|
||||||
<TextBlock x:Name="Path" Grid.Column="1" Text="C:\Program Files\WindowsApps\Microsoft\Folder " Grid.Row="1" Opacity="0.6" VerticalAlignment="Top"/>
|
<TextBlock x:Name="Path" Grid.Column="1" Text="C:\Program Files\WindowsApps\Microsoft\Folder " Grid.Row="1" Opacity="0.6" VerticalAlignment="Top"/>
|
||||||
<StackPanel Orientation="Horizontal" Opacity="0" HorizontalAlignment="Right" Grid.RowSpan="2" Grid.Column="1">
|
<StackPanel Orientation="Horizontal" Opacity="0" HorizontalAlignment="Right" Grid.RowSpan="2" Grid.Column="1">
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
|||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
using Windows.UI.Xaml.Input;
|
||||||
|
|
||||||
namespace PowerLauncher
|
namespace PowerLauncher
|
||||||
{
|
{
|
||||||
@@ -260,9 +261,9 @@ namespace PowerLauncher
|
|||||||
_launcher = (PowerLauncher.UI.LauncherControl)host.Child;
|
_launcher = (PowerLauncher.UI.LauncherControl)host.Child;
|
||||||
_launcher.DataContext = _viewModel;
|
_launcher.DataContext = _viewModel;
|
||||||
_launcher.SearchBox.TextChanged += QueryTextBox_TextChanged;
|
_launcher.SearchBox.TextChanged += QueryTextBox_TextChanged;
|
||||||
_launcher.SearchBox.SuggestionChosen += SearchBox_SuggestionChosen;
|
_launcher.SearchBox.SuggestionChosen += AutoSuggestBox_SuggestionChosen;
|
||||||
|
_launcher.SearchBox.QuerySubmitted += AutoSuggestBox_QuerySubmitted;
|
||||||
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
|
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
|
||||||
|
|
||||||
_viewModel.PropertyChanged += (o, e) =>
|
_viewModel.PropertyChanged += (o, e) =>
|
||||||
{
|
{
|
||||||
if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
|
if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
|
||||||
@@ -282,12 +283,21 @@ namespace PowerLauncher
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
|
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
|
||||||
{
|
{
|
||||||
if (args != null)
|
if(args != null && args.SelectedItem != null)
|
||||||
{
|
{
|
||||||
ResultViewModel result = (ResultViewModel)args.SelectedItem;
|
ResultViewModel result = (ResultViewModel)args.SelectedItem;
|
||||||
_ = result.Result.Action != null && result.Result.Action(new ActionContext{});
|
sender.Text = result.Result.Title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args != null && args.ChosenSuggestion != null)
|
||||||
|
{
|
||||||
|
ResultViewModel result = (ResultViewModel)args.ChosenSuggestion;
|
||||||
|
_ = result.Result.Action != null && result.Result.Action(new ActionContext { });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user