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

NullReferenceException when trying to remove selected item in NavigationView 2.1.0-preview6 #588

Open
OleRoss opened this issue Jun 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@OleRoss
Copy link

OleRoss commented Jun 24, 2024

Describe the bug
Following bug 572, when I try to clear the items, I get a NullReferenceException.

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at FluentAvalonia.UI.Controls.NavigationView.RaiseItemInvoked(Object item, Boolean isSettings, NavigationViewItemBase container, NavigationRecommendedTransitionDirection recDir)
   at FluentAvalonia.UI.Controls.NavigationView.ChangeSelection(Object prevItem, Object nextItem)
   at FluentAvalonia.UI.Controls.NavigationView.OnSelectedItemPropertyChanged(Object oldItem, Object newItem)
   at FluentAvalonia.UI.Controls.NavigationView.OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
   at Avalonia.AvaloniaObject.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs change)
   at Avalonia.Animation.Animatable.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs change)
   at Avalonia.AvaloniaObject.RaisePropertyChanged[T](AvaloniaProperty`1 property, Optional`1 oldValue, BindingValue`1 newValue, BindingPriority priority, Boolean isEffectiveValue)
   at Avalonia.AvaloniaObject.SetAndRaise[T](DirectPropertyBase`1 property, T& field, T value)
   at FluentAvalonia.UI.Controls.NavigationView.set_SelectedItem(Object value)
   at FluentAvalonia.UI.Controls.NavigationView.SetSelectedItemAndExpectItemInvokeWhenSelectionChangedIfNotInvokedFromAPI(Object selItem)
   at FluentAvalonia.UI.Controls.NavigationView.OnSelectionModelSelectionChanged(Object sender, SelectionModelSelectionChangedEventArgs e)
   at FluentAvalonia.UI.Controls.SelectionModel.OnSelectionChanged()
   at FluentAvalonia.UI.Controls.SelectionModel.OnSelectionInvalidatedDueToCollectionChange()
   at FluentAvalonia.UI.Controls.SelectionNode.OnSourceListChanged(Object dataSource, NotifyCollectionChangedEventArgs args)
   at Avalonia.Controls.ItemsSourceView.Avalonia.Controls.Utils.ICollectionChangedListener.Changed(INotifyCollectionChanged sender, NotifyCollectionChangedEventArgs e)
   at Avalonia.Controls.Utils.CollectionChangedEventManager.Entry.<Avalonia.Utilities.IWeakEventSubscriber<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.OnEvent>g__Notify|6_0(INotifyCollectionChanged incc, NotifyCollectionChangedEventArgs args, WeakReference`1[] listeners)
   at Avalonia.Controls.Utils.CollectionChangedEventManager.Entry.Avalonia.Utilities.IWeakEventSubscriber<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.OnEvent(Object notifyCollectionChanged, WeakEvent ev, NotifyCollectionChangedEventArgs e)
   at Avalonia.Utilities.WeakEvent`2.Subscription.OnEvent(Object sender, TEventArgs eventArgs)
   at Avalonia.Utilities.WeakEvents.<>c__DisplayClass5_0.<.cctor>b__5(Object _, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at AvaloniaTests.ViewModels.MainWindowViewModel.Test() in C:\Users\OleRosskamp\RiderProjects\AvaloniaTests\AvaloniaTests\ViewModels\MainWindowViewModel.cs:line 16
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
   at Avalonia.Threading.DispatcherOperation.Execute()
   at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
   at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
   at Avalonia.Threading.Dispatcher.Signaled()
   at Avalonia.Win32.Win32DispatcherImpl.DispatchWorkItem()
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
   at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
   at AvaloniaTests.Program.Main(String[] args) in C:\Users\OleRosskamp\RiderProjects\AvaloniaTests\AvaloniaTests\Program.cs:line 13

Screenshots
Minimal Repo: https://github.com/OleRoss/AvaloniaTests/tree/fe2bdf7f811452f934bf975e09f2cd06069a727a

The repo is the same as before, I just updated to preview6 and avalonia rc1.
Steps to reproduce:

  • Select the first nav-view item (do not click on button)
  • Click on button
    -> Exception

image

Desktop/Platform (please complete the following information):

  • OS: Windows 11
  • FluentAvalonia Version 2.1.0-preview6
  • Avalonia Version 11.1.0-rc1
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