Many child Views (UserControls) inside a big UserControl

Nov 15, 2010 at 11:36 PM

Hello again Marlon,

I have this situation:

I have a in my Main window a contentcontrol where I switch the views(usercontrols) via [ExportViewModel("BillingVM",true)]. Thats all fine working, thanks.

One of those views is e.g. a BillingView.xaml which contains SIX other views(UserControls). All these UControls depending on each other (customer 1:N Order 1:N Products...) therefore

all SIX views has the DataContext of the BillingView.xaml which is the BillingVM. 

 

Well the BillingView.xaml is created ONE time.

The other 6 views are created everytime I switch the contentcontrol to the BillingView.

How can I prevent this? I know the solution could be using a ViewModel for each of the SIX views, but then I have trouble with changing the aggregated data to the current customer etc... and

display the proper data. I am not a friend of firing around the selectedCustomer,selectedOrder,selectedProduct etc... to keep my SIX views in sync... thats a lot of infrastructure code

not really needed.

 

Do you have any good advice with MEFedMVVM in this situation?