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

NavigationView ItemInvoked returning incorrect item fix #2682

Merged
merged 5 commits into from
Aug 4, 2020

Conversation

ojhad
Copy link
Contributor

@ojhad ojhad commented Jun 16, 2020

Description

In the scenario where MenuItemTemplate/MenuItemTemplateSelector returns a UIElement that is not derived from NavigationViewItemBase, the ItemInvoked callback returns the UIElement instead of the expected data item provided via MenuItemsSource.

This is because in the ItemsRepeater NV implementation, we internally wrap this UIElement in a NavigationViewItem. This is done by setting the content property of a NavigationViewItem to the returned UIElement. This breaks expectation from the ListView implementation as the content property should be set to the actual data item.

Fixed this issue by updating the wrapping logic to pass down the content and ItemTemplate down to the NavigationViewItem's content presenter to resolve.

Note:
I still have to figure out the best way to recycle the returned UIElement, so for now I left it as a todo. Depending on when I find a good way to do this, I will either update this PR or file a new issue.

Motivation and Context

Fixes #2520

How Has This Been Tested?

Added new interaction test

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Jun 16, 2020
@ojhad
Copy link
Contributor Author

ojhad commented Jun 16, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters StephenLPeters added area-NavigationView NavView control team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Jun 16, 2020
@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

Please merge with master to pick up the GLS const enforcement change and make sure you don't have any build failures from that.

@StephenLPeters
Copy link
Contributor

@ojhad This looks blocked by the merge conflict

@ojhad
Copy link
Contributor Author

ojhad commented Aug 4, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@StephenLPeters StephenLPeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ojhad
Copy link
Contributor Author

ojhad commented Aug 4, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ojhad ojhad merged commit c2d4b16 into master Aug 4, 2020
@ojhad ojhad deleted the user/diojha/iteminvokefix branch August 4, 2020 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NavigationView NavView control team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NavigationView in 2.4 doesn't return the Item anymore in ItemInvoked
5 participants