Absence of null reference checking when removing items from NavigationView.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
If the NavigationView control is bound to a collection of NavigationViewItem, when one of the item in the collection is about to be removed, the OnMenuItemsSource_CollectionChanged method will be invoked with e.Action = NotifyCollectionChangedAction.Remove. Before the actual removal, the NewItems is checked in case it's also in the OldItems to avoid delete and adding again. However, the NewItems might be null so that null reference exception was occured.
To Reproduce
Create a NaviagtionView and bind its MenuItems to a ObservableCollection, and then remove one of the item in the colloction.
Expected behavior
the items to be removed successfully
Screenshots
OS version
Win 11
.NET version
8.0
WPF-UI NuGet version
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating NavigationView's OnMenuItemsSource_CollectionChanged method and reproduce the issue with a NavigationView bound to an ObservableCollection. Verify the collection item can be removed without a null reference exception and that the remaining navigation items are unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100