So I've tried and tried to get my head around CAL as I can see the benefits and really want to take advantage of them.
However, there's a lot to learn, so I thought I'd start by breaking down the proverbial elephant into smaller more manageable pieces.
I think I understand Unity.
I'm also pretty sure I've got the MVVM pattern figured out.
I'm comfortable with the basic concepts of CAL, but implementing them is sometimes a bit confusing.
So now I have some kind of foundation to build on I'm trying to put the pieces together using CAL.
In my approach to MVVM I've always tried to have the purest implementation possible.
(You may well question my definition of pure but here goes).
The view knows absolutely nothing about the view model and the view model knows absolutely nothing about the view.
My view model implements INotifyPropertyChanged and exposes properties that the view can bind to.
Now I don't know if I'm doing this right, but I then have another class (which I don't have a name for) which instantiates a view, instantiates a viewmodel and wires the two together (view.datacontext = viewmodel).
Question 1; Am I doing this right? or is my interpretation of the MVVM pattern not the norm?
Question 2; CAL View Discovery.
The quickstarts all suggest that the viewmodel exposes a view property and that's what they use for registering the view in the viewregistry.
My viewmodels don't do this however, which leaves me confused.
Obviously I can use the Unity to resolve my view class when calling RegisterViewWithRegion, which works in terms of it successfully shows the view, but how do I then wire that up to a viewmodel to make all the good stuff happen?
I'm thinking along the lines of....
In my module.initialise use the unity container to resolve both the view and the viewmodel as ContainerControlledLifetimeManaged objects (ie. single instance).
Then grab a reference to each of those objects and wire them together.
Finally, register the view with the view registry, again, using unity to resolve the view.
I think that would work, to be honest I haven't tried it, but in truth I'm not completely convinced that this is the way it was supposed to work.
Comments, advice and feedback would be appreciated.