Updated functionality on suggestion chosen in autosuggestbox

This commit is contained in:
Divyansh 2020-04-06 09:23:08 -07:00
parent 1a15a062ef
commit abbaca3c71

View File

@ -260,26 +260,26 @@ namespace PowerLauncher
_launcher = (PowerLauncher.UI.LauncherControl)host.Child;
_launcher.DataContext = _viewModel;
_launcher.SearchBox.TextChanged += QueryTextBox_TextChanged;
//_launcher.SearchBox.SuggestionChosen += SearchBox_SuggestionChosen;
//_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
_launcher.SearchBox.SuggestionChosen += SearchBox_SuggestionChosen;
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
//_viewModel.PropertyChanged += (o, e) =>
//{
// if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
// {
// if (Visibility == System.Windows.Visibility.Visible)
// {
// Activate();
// _launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
// UpdatePosition();
// _settings.ActivateTimes++;
// if (!_viewModel.LastQuerySelected)
// {
// _viewModel.LastQuerySelected = true;
// }
// }
// }
//};
_viewModel.PropertyChanged += (o, e) =>
{
if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
{
if (Visibility == System.Windows.Visibility.Visible)
{
Activate();
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
UpdatePosition();
_settings.ActivateTimes++;
if (!_viewModel.LastQuerySelected)
{
_viewModel.LastQuerySelected = true;
}
}
}
};
}
private void SearchBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
@ -287,15 +287,8 @@ namespace PowerLauncher
if (args != null)
{
ResultViewModel result = (ResultViewModel)args.SelectedItem;
bool hideWindow = result.Result.Action != null && result.Result.Action(new ActionContext
{
});
if (!hideWindow)
{
Console.WriteLine("here");
}
}
_ = result.Result.Action != null && result.Result.Action(new ActionContext{});
}
}
private void QueryTextBox_TextChanged(Windows.UI.Xaml.Controls.AutoSuggestBox sender, Windows.UI.Xaml.Controls.AutoSuggestBoxTextChangedEventArgs args)