Should I register ViewModels in Container and resolve from there?
Benefits:
- I can perform some actions when view model is activated
- Container will inject dependencies for me
- ???
Drawbacks:
- ViewModel lifetime management can be tricky:
- if I make ViewModel singleton then I can't instantiate several controls of the same type
- if I make ViewModel transient then I can easily end up in a situation of having several different instances when I actually expect same instance injected
- ???
What's the right answer? I'd prefer to register if I could mitigate lifetime drawback.
I'm using Caliburn and Autofac if it matters.