diff --git a/src/Ryujinx/UI/ViewModels/UserProfileViewModel.cs b/src/Ryujinx/UI/ViewModels/UserProfileViewModel.cs index 7f4d18ba7..792f9ea0a 100644 --- a/src/Ryujinx/UI/ViewModels/UserProfileViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/UserProfileViewModel.cs @@ -1,7 +1,7 @@ using Ryujinx.Ava.UI.Models; using System; using System.Collections.ObjectModel; -using System.Linq; +using System.Collections.Specialized; namespace Ryujinx.Ava.UI.ViewModels { @@ -11,23 +11,32 @@ namespace Ryujinx.Ava.UI.ViewModels { Profiles = new ObservableCollection(); LostProfiles = new ObservableCollection(); + LostProfiles.CollectionChanged += LostProfilesChanged; } - public ObservableCollection Profiles { get; set; } + public ObservableCollection Profiles { get; } - public ObservableCollection LostProfiles { get; set; } + public ObservableCollection LostProfiles { get; } - public bool IsEmpty => !LostProfiles.Any(); + public bool IsEmpty => LostProfiles.Count == 0; public void Dispose() { - GC.SuppressFinalize(this); + LostProfiles.CollectionChanged -= LostProfilesChanged; + } + + private void LostProfilesChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnPropertyChanged(nameof(IsEmpty)); } public void UpdateLostProfiles(ObservableCollection newProfiles) { - LostProfiles = newProfiles; - OnPropertyChanged(nameof(LostProfiles)); + LostProfiles.Clear(); + + foreach (var profile in newProfiles) + LostProfiles.Add(profile); + OnPropertyChanged(nameof(IsEmpty)); } }