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

Issue with NavigationViewExtensions.SelectedIndex Property #1905

Closed
michael-hawker opened this issue Mar 19, 2018 · 0 comments
Closed

Issue with NavigationViewExtensions.SelectedIndex Property #1905

michael-hawker opened this issue Mar 19, 2018 · 0 comments
Assignees
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior extensions ⚡

Comments

@michael-hawker
Copy link
Member

I'm submitting a...

  • Bug report (I searched for similar issues and did not find one)

Current behavior

In some advanced scenarios, the selected item of the NavigationView is set to null when the user selects an item.

Expected behavior

SelectedItem not set to null...

Minimal reproduction of the problem with instructions

Wasn't able to see it in sample app even though my project uses the same structure. Think it has to do with something binding to the selecteditem elsewhere maybe. Anyway, was able to fix the issue with logic here on line 148.

Should be

            if (value >= 0 && value < navview.MenuItems.Count)
            {
                // Only update if we need to.
                if (navview.SelectedItem == null || !navview.SelectedItem.Equals(navview.MenuItems[value] as NavigationViewItem))
                {
                    navview.SelectedItem = navview.MenuItems[value];
                }
            }

Then worked like a charm, thought there was something wrong with my app... I'll submit a PR soon.

Environment

Nuget Package(s): 2.2

Package Version(s): 

Windows 10 Build Number:
- [ ] Anniversary Update (14393) 
- [ ] Creators Update (15063)
- [x] Fall Creators Update (16299)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Anniversary Update (14393) 
- [ ] Creators Update (15063)
- [x] Fall Creators Update (16299)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [x] 2017 (version: )
- [ ] 2017 Preview (version: )

@michael-hawker michael-hawker added bug 🐛 An unexpected issue that highlights incorrect behavior extensions ⚡ labels Mar 19, 2018
@michael-hawker michael-hawker self-assigned this Mar 19, 2018
michael-hawker added a commit that referenced this issue Mar 19, 2018
We would sometimes in error set the SelectedItem to null due to an issue with comparing to the com object from the MenuItems list.

Now we do a safer check and avoid resetting the item if its the same, and if we gave a valid index avoid setting to null if we do fail.
azchohfi added a commit that referenced this issue Mar 19, 2018
…onfix

Fix for NavigationView SelectedIndex Bug #1905
OpportunityLiu added a commit to OpportunityLiu/UWPCommunityToolkit that referenced this issue Apr 12, 2018
* Change the background color of items when they are added or removed

* extract method for common logic

* only need to go from the index the item was inserted/removed

* Ignore items to the end of the list, we'll handle that in another method

* unsubscribe from events and remove the list when it's been unloaded

* move methods to the bottom below changed handlers

* unsubscribe from all list events when it is unloaded

* Inherit from HeaderedContentControl to remove duplicate properties

* Change default StepFrequency to 1 to match Slider

* Change sample to use a regular slider for StepFrequency

* Added ItemContainerStyleSelector

ItemContainerStyleSelector allows for code to change the ItemContainerStyle on the fly

* Fix for NavigationView SelectedIndex Bug CommunityToolkit#1905

We would sometimes in error set the SelectedItem to null due to an issue with comparing to the com object from the MenuItems list.

Now we do a safer check and avoid resetting the item if its the same, and if we gave a valid index avoid setting to null if we do fail.

* Strectch the content of the expander header to allow for other content

* Update PULL_REQUEST_TEMPLATE.md

* Use the index from the arguments rather than getting it from the container

* Get the proper command bar added

* Extract command logic

* Removing Moldavian

* Add Initial HeaderStyle Property to Expander

* Move Height of Expander Header into Template

* Update Expander Docs

* fixed relative links in docs

* attempting to fix dependency issue

* updated version of gitversioning

* updated gitversioning version

* revert msbuild.sdk.extras

* Removed obsolete comment from build script

* Remove duplicate compositeTransform.CenterY

* Fixed a NullReferenceException in AdvancedCollectionView Filter
When setting a filter, then resetting it to null,
an exception occured. This has been fixed.

* Fix crash (CommunityToolkit#1913).
@ghost ghost locked as resolved and limited conversation to collaborators Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior extensions ⚡
Projects
None yet
Development

No branches or pull requests

2 participants