Hello again, I wanna start with a big thank you for your help so far..
..and continue with a new question:
I have a page containing my Batches on the left and the details for the selected one on the right.
Each batch has a number of 'RequestGroups' each containing a Request, Production and Uses. Each Request has a list of RequestedBottleType, and same for the Production (ProducedBottleType instead). I'm not going to go into the Uses as for the example that follows
there aren't any.
Everything 'loads', 'modifies', 'saves' fine. My problem comes when unloading(in this example I'm navigating to another page, but the nature of the problem is the same when selecting a different batch).
The problem isn't visible to the user but on the debugger window I see things that seem quite wrong: starting the navigation process, the BatchViewModel is unloaded, and then reloaded with a null context- this causes a number of errors caused by the view's
null bindings, then the first child is unloaded (RequestGroupsViewModle), that in turn unloads it's children but not before reloading them with a null context(some more errors). Finally after everything is unloaded, the BatchesPage is reloaded and subsequently
the BatchViewModel get's constructed with the SelectedBatch and in turn constructing all the children anew. Then everything is once again unloaded(same story as before) and finally we are free to navigate to the new page.
A few things worth mentioning: I'm still using ModernUI for the navigation. In my views I have a setup for dealing with the case where the binding target for the user control is null, where instead I would show a 'add new' button(say for a Production) based
on a ControlTemplate with DataTrigger, so as to not have to load a ProductionViewModel with a null context. Are there any good practices for dealing with the null context scenario(with an example such as Request.Production==null)?
I'm sorry for what follows is quite long but I hope it would shed some light for you because I'm completely in the dark here :)
- My writeLines, in the form "Title + closing: Model.ID " are from the close() method in the VM's(excl. the ***Bottles VMs)