lepoco / lepoco/wpfui

Absence of null reference checking when removing items from NavigationView.

Open
#1,224 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

image

OS version

Win 11

.NET version

8.0

WPF-UI NuGet version
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.