Skip to content

Commit

Permalink
NavigationViewItem input handling fixes (#2625)
Browse files Browse the repository at this point in the history
* NavigationViewItem fixes including WinUI3 26317023

* Applying PR feedback & merging with master.
  • Loading branch information
RBrid authored Jun 10, 2020
1 parent 52c6013 commit f3da94f
Show file tree
Hide file tree
Showing 18 changed files with 474 additions and 141 deletions.
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

0 comments on commit f3da94f

Please sign in to comment.