Inside the model there is a live list of devices, each device has its own fields. How to notify the list in the VM, so that he updated the View?
Updating the fields in this list could be done through INPC, but it seems to me that this is not the best option, since the model is cluttered and it is not possible to serialize it binary. I see that it is necessary to write an additional model to the existing ones and notify about changes in it, but then you need to adjust the logic in order to work with these classes, and not with the model itself.
Model:
[Serializable] public class Group { public string Name { get; set; } public List<Computer> PCList { get; set; } } [Serializable] public class Computer { public string Name { get; set; } public bool Status { get; set; } } Logics:
public class Logic { private List<Group> _Groups; public List<Group> Groups { get { return _Groups; } set { _Groups = value; } } // code public Logic() { // code _Groups = LoadGroups(); _Server.Start(); } private void ClientConnectedEvent(object sender, MyArgs e) { Computer comp = new Computer(); // code _Groups[0].PCList.Add(comp); } } VM:
public class MainWindowViewModel { public MainWindowViewModel() { Groups = new ObservableCollection<Group>(App.Logic.Groups); } public ObservableCollection<Group> Groups { get; set; } }
Device(orDeviceDto), which you can normally deserialize. And in VM there will be aDeviceVMclass to which the View will bind, with all the INPCs and so on. When a VM polls a model, it returns theDevicelist to it, and the VM based on it makes itself a list already fromDeviceVM(ObservableCollection<DeviceVM>). Then, when you figure it out, you can connect some mapper (for example, AutoMapper) and entrust the work on converting model classes to Vm ones (well, this is optional, just to let you know that there is such an opportunity)