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

Absence of null reference checking when removing items from NavigationView. #1224

Open
zhrtc opened this issue Sep 6, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@zhrtc
Copy link

zhrtc commented Sep 6, 2024

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

@zhrtc zhrtc added the bug Something isn't working label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant