Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AutoSuggestBox SuggestionChosen Event to QuerySubmitted for NavView #5488

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dev/NavigationView/NavigationView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void NavigationView::UnhookEventsAndClearFields(bool isFromDestructor)
if (isFromDestructor)
{
m_selectionChangedRevoker.revoke();
m_autoSuggestBoxSuggestionChosenRevoker.revoke();
m_autoSuggestBoxQuerySubmittedRevoker.revoke();
}
}

Expand Down Expand Up @@ -3974,11 +3974,11 @@ void NavigationView::OnPropertyChanged(const winrt::DependencyPropertyChangedEve
InvalidateTopNavPrimaryLayout();
if (args.OldValue())
{
m_autoSuggestBoxSuggestionChosenRevoker.revoke();
m_autoSuggestBoxQuerySubmittedRevoker.revoke();
}
if (const auto newAutoSuggestBox = args.NewValue().try_as<winrt::AutoSuggestBox>())
{
m_autoSuggestBoxSuggestionChosenRevoker = newAutoSuggestBox.SuggestionChosen(winrt::auto_revoke, {this, &NavigationView::OnAutoSuggestBoxSuggestionChosen });
m_autoSuggestBoxQuerySubmittedRevoker = newAutoSuggestBox.QuerySubmitted(winrt::auto_revoke, {this, &NavigationView::OnAutoSuggestBoxQuerySubmitted });
}
UpdateVisualState(false);
}
Expand Down Expand Up @@ -4725,10 +4725,10 @@ void NavigationView::UpdateTitleBarPadding()
}
}

void NavigationView::OnAutoSuggestBoxSuggestionChosen(const winrt::AutoSuggestBox& sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxSuggestionChosenEventArgs& args)
void NavigationView::OnAutoSuggestBoxQuerySubmitted(const winrt::AutoSuggestBox& sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxQuerySubmittedEventArgs& args)
{
// When in compact or minimal, we want to close pane when an item gets selected.
if (DisplayMode() != winrt::NavigationViewDisplayMode::Expanded && args.SelectedItem() != nullptr)
// When in compact or minimal, we want to close pane when an item gets chosen.
if (DisplayMode() != winrt::NavigationViewDisplayMode::Expanded && args.ChosenSuggestion() != nullptr)
{
ClosePane();
}
Expand Down
4 changes: 2 additions & 2 deletions dev/NavigationView/NavigationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class NavigationView :
void OnTitleBarIsVisibleChanged(const winrt::CoreApplicationViewTitleBar& sender, const winrt::IInspectable& args);
void UpdateTitleBarPadding();

void OnAutoSuggestBoxSuggestionChosen(const winrt::AutoSuggestBox& sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxSuggestionChosenEventArgs& args);
void OnAutoSuggestBoxQuerySubmitted(const winrt::AutoSuggestBox& sender, const winrt::Windows::UI::Xaml::Controls::AutoSuggestBoxQuerySubmittedEventArgs& args);

void RaiseDisplayModeChanged(const winrt::NavigationViewDisplayMode& displayMode);
void AnimateSelectionChanged(const winrt::IInspectable& currentItem);
Expand Down Expand Up @@ -411,7 +411,7 @@ class NavigationView :
winrt::UIElement::AccessKeyInvoked_revoker m_accessKeyInvokedRevoker{};
winrt::FrameworkElement::SizeChanged_revoker m_paneTitleHolderFrameworkElementSizeChangedRevoker{};
winrt::FrameworkElement::SizeChanged_revoker m_itemsContainerSizeChangedRevoker{};
winrt::AutoSuggestBox::SuggestionChosen_revoker m_autoSuggestBoxSuggestionChosenRevoker{};
winrt::AutoSuggestBox::QuerySubmitted_revoker m_autoSuggestBoxQuerySubmittedRevoker{};

winrt::ItemsRepeater::ElementPrepared_revoker m_leftNavItemsRepeaterElementPreparedRevoker{};
winrt::ItemsRepeater::ElementClearing_revoker m_leftNavItemsRepeaterElementClearingRevoker{};
Expand Down