Jun 7, 2011 at 9:17 PM
Edited Jun 7, 2011 at 9:21 PM
We are using unity in MVVM for a ViewModelLocator.
We have situations where there maybe many Views that share a single instance of a ViewModel. What I would like to be able to do is create a singleton that would last until I destroy it. Then as the one of the Views is accessed again it will create a new
ViewModel through the Resolve method. We have the locator as a global StaticResource in our application. SO we dont really have direct code access to the instance of the container.
I have of course seen ExternallyControlledLifetimeManager but having trouble finding an example that uses it in the way that I would like...
So basically I need a singleton class capability but the lifetime of the ViewModel will be shorter than the container life time but longer than multiple requests to the Resolve method... Is there a way to do that?