I have made a lot of progress with my ViewModel implementation. For week I was using a single Root object based ViewModel. I have now successfully created ViewModels for each object in the object graph, and have also trasferred most of my code-behind into the appropriate VMs.
Parts of my object graph are created/fetched at the outset, and parts will be lazy-loaded (and are not even implemented yet). All child object VMs are created using a constructor that is sent the object as a parameter.
Right now there is only one BusinessListBase collection, and that is giving me an error. The error says "BeginEdit is not valid on a child object" and occures when VM's Model property is set to my List in the ViewModelBase. I see in SlDemo the EmployeeListViewModel being created with the Parameterless constructor using BeginRefresh("GetEmployeeList");
The phrase BeginEdit does not even occur anywhere in my solution. Is there something wrong with my List that is generating this error?
ViewModelBase defaults to ManageObjectLifetime=true, which means it calls BeginEdit/CancelEdit/ApplyEdit on your behalf. You can set ManageObjectLifetime=false in your constructor to prevent this behavior, which is usually what you want to do for anything other than the root object - and you want to set it to false for a root object if your UI has no concept of a cancel button.
Fantastic. Thank you. That makes perfect sense.
Jav
Copyright (c) Marimer LLC