0
votes

I'm trying to develop a PRISM WPF application where I am going to have two or more views depending on the same ViewModel. At first I thought of using Unity to do an injection through the view's constructor and within the constructor set the DataContext. That idea was dismissed by the team because they want nothing in the code-behind. Moreover, the views are using a ViewModelLocator that is Autowired to the ViewModel. So then my only other thought doing a Module with a single view, but then how do I go about sharing the same ViewModel between modules if I'm using Unity IOC? Any ideas with some kind of example?

1

1 Answers

0
votes

Don't share ViewModels instances between views. Just load data as you need it. But if you must shoot yourself in the foot there are many ways to do it. The easiest would be to register your ViewModel as a singleton in your container.