namespace DashBoard.ViewModel; internal partial class DashBoardMainViewModel : ObservableObject { public DashBoardMainViewModel(DeviceCollection deviceCollection, IDialogService dialogService) { this._DeviceCollection = deviceCollection; this._DialogService = dialogService; deviceCollection.DeviceList.CollectionChanged += DeviceList_CollectionChanged; this.DeviceList_CollectionChanged(deviceCollection.DeviceList, null); } private void DeviceList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs? e) { if (sender is not ObservableDictionary deviceList) return; this.Devices.Clear(); foreach (DeviceInfo_VM device in deviceList.Values) { this.Devices[device.DeviceModel] ??= []; this.Devices[device.DeviceModel].Add(device); } } private readonly IDialogService _DialogService; private readonly DeviceCollection _DeviceCollection; [ObservableProperty] private ObservableDictionary> _Devices = []; }