I use MVVM navigaion. I have Main Window, and I navigate to child user controls. On the user controls I create instance of their viewmodel. So I wonder, which instance of the viewmodel will be taken, the one created on the mainwindow, or the one from the usercontrol, and is it problematic, that I create two instances? Main Window with DataTemplates:
<Window.Resources>
<DataTemplate DataType="{x:Type cust:CustomersListViewModel}">
<cust:CustomerListView></cust:CustomerListView>
</DataTemplate>
<DataTemplate DataType="{x:Type dealer:DealersViewModel}">
<dealer:DealersView></dealer:DealersView>
</DataTemplate>
</Window.Resources>
I Create instances of child user controls :
Customers.CustomersListViewModel customersViewModel = new Customers.CustomersListViewModel();
Dealers.DealersViewModel dealersViewModel = new Dealers.DealersViewModel();
And I bind to child user controls with : ` On the user controls I create viewmodel instance:
<UserControl.DataContext>
<local:CustomersListViewModel></local:CustomersListViewModel>
</UserControl.DataContext>
So is it problematic that I create to instances of view model?