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

NavigationViewItem input handling fixes #2625

Merged
merged 3 commits into from
Jun 10, 2020
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
10 changes: 9 additions & 1 deletion dev/Generated/NavigationViewItemBase.properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void NavigationViewItemBaseProperties::EnsureProperties()
winrt::name_of<winrt::NavigationViewItemBase>(),
false /* isAttached */,
ValueHelper<bool>::BoxedDefaultValue(),
nullptr);
winrt::PropertyChangedCallback(&OnIsSelectedPropertyChanged));
}
}

Expand All @@ -40,6 +40,14 @@ void NavigationViewItemBaseProperties::ClearProperties()
s_IsSelectedProperty = nullptr;
}

void NavigationViewItemBaseProperties::OnIsSelectedPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args)
{
auto owner = sender.as<winrt::NavigationViewItemBase>();
winrt::get_self<NavigationViewItemBase>(owner)->OnPropertyChanged(args);
}

void NavigationViewItemBaseProperties::IsSelected(bool value)
{
static_cast<NavigationViewItemBase*>(this)->SetValue(s_IsSelectedProperty, ValueHelper<bool>::BoxValueIfNecessary(value));
Expand Down
4 changes: 4 additions & 0 deletions dev/Generated/NavigationViewItemBase.properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ class NavigationViewItemBaseProperties

static void EnsureProperties();
static void ClearProperties();

static void OnIsSelectedPropertyChanged(
winrt::DependencyObject const& sender,
winrt::DependencyPropertyChangedEventArgs const& args);
};
3 changes: 0 additions & 3 deletions dev/NavigationView/NavigationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class NavigationView :

private:

void OnRepeaterGettingFocus(const winrt::IInspectable& sender, const winrt::GettingFocusEventArgs& args);

// Selection handling functions
void OnNavigationViewItemIsSelectedPropertyChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args);
void OnSelectionModelSelectionChanged(const winrt::SelectionModel& selectionModel, const winrt::SelectionModelSelectionChangedEventArgs& e);
Expand Down Expand Up @@ -261,7 +259,6 @@ class NavigationView :
void OnNavigationViewItemOnGotFocus(const winrt::IInspectable& sender, const winrt::RoutedEventArgs& e);
void OnNavigationViewItemExpandedPropertyChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args);

void OnOverflowItemSelectionChanged(const winrt::IInspectable& sender, const winrt::SelectionChangedEventArgs& args);
void RaiseSelectionChangedEvent(winrt::IInspectable const& nextItem,
bool isSettingsItem,
NavigationRecommendedTransitionDirection recommendedDirection = NavigationRecommendedTransitionDirection::Default);
Expand Down
3 changes: 3 additions & 0 deletions dev/NavigationView/NavigationView.idl
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,15 @@ unsealed runtimeclass NavigationView : Windows.UI.Xaml.Controls.ContentControl
[webhosthidden]
[WUXC_INTERFACE_NAME("INavigationViewItemBase", edf04eb1-37d1-471f-8570-3829ee5b2bc6)]
[WUXC_CONSTRUCTOR_NAME("INavigationViewItemBaseFactory", eb014cef-7890-4ebb-8245-02e8510f321d)]
[MUX_PROPERTY_CHANGED_CALLBACK_METHODNAME("OnPropertyChanged")]
[default_interface]
unsealed runtimeclass NavigationViewItemBase : Windows.UI.Xaml.Controls.ContentControl
{
[WUXC_VERSION_MUXONLY]
{
[MUX_PROPERTY_CHANGED_CALLBACK(TRUE)]
Boolean IsSelected{ get; set; };

static Windows.UI.Xaml.DependencyProperty IsSelectedProperty { get; };
}
}
Expand Down
2 changes: 1 addition & 1 deletion dev/NavigationView/NavigationViewHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NavigationViewItemHelper
{
}

winrt::UIElement GetSelectionIndicator() { return m_selectionIndicator.get(); }
winrt::UIElement GetSelectionIndicator() const { return m_selectionIndicator.get(); }

void Init(const winrt::IControlProtected & controlProtected)
{
Expand Down
Loading