wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

Absence of null reference checking when removing items from NavigationView.

Open zhrtc opened this issue 1 year ago • 0 comments

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 avatar Sep 06 '24 09:09 zhrtc