Skip to content

Commit

Permalink
fix: Make NavigationView Settings item selectable
Browse files Browse the repository at this point in the history
- Fixes #4809 - in some cases on some Uno targets, the lifecycle events are in such order that causes presenters of dynamically added NavigationViewItems not to be initialized properly. These changes work around this problem when selection indicator is requeste. These changes can be reverted when #4689 is fixed.
  • Loading branch information
MartinZikmund committed Dec 30, 2020
1 parent f17770d commit 69318b4
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ protected override void OnApplyTemplate()
var navigationViewItem = GetNavigationViewItem();
if (navigationViewItem != null)
{
#if IS_UNO
// TODO: Uno specific: We may be reapplying the template, in which case
// we need to unsubscribe the previous Tapped event handler.
// Can be removed when #4689.
if (m_expandCollapseChevron != null)
{
m_expandCollapseChevron.Tapped -= navigationViewItem.OnExpandCollapseChevronTapped;
}
#endif

var expandCollapseChevron = GetTemplateChild(c_expandCollapseChevron) as Grid;
if (expandCollapseChevron != null)
{
Expand Down Expand Up @@ -87,7 +97,19 @@ internal void RotateExpandCollapseChevron(bool isExpanded)

internal UIElement GetSelectionIndicator()
{
return m_helper.GetSelectionIndicator();
#if IS_UNO
// TODO: Uno specific: This is done to ensure that the presenter
// was initialized properly - if helper is not null, but content grid
// is null, it means the presenter was not initialized correctly.
// Can be removed when #4809 is fixed.
if (m_contentGrid == null && m_helper != null)
{
// Reinitialize
OnApplyTemplate();
}
#endif
// m_helper could be null here, if template was not yet applied
return m_helper?.GetSelectionIndicator();
}

protected override bool GoToElementStateCore(string state, bool useTransitions)
Expand Down

0 comments on commit 69318b4

Please sign in to comment.