简体   繁体   中英

How do i do master detail implementation with WPF MVVM and Entity framework

I have four entity Customer, product, order and order details. On my WPF window I have customer list box showing customer name and on select of customer I would like to populate the order list box which also in my window.

Since i am using MVVM, I should have two view model, one for customer and another for order, right? and i should pass the customer to orderview model so that it can populate the orderview.

How do I even pass selected customer to the order view model? I have a property named selected item on customer., but I still dont c how shall I get that in my order view model.

Update:

@Craig Trombly I have created the ObservableCollection of my order entity and has property on my view model that is binding to in Xaml. I am implementing master detail behavior like on select of customer populate my order list box. For that i need to have a property on my customer view model and I am binding that property to selectedItem in the list box in my customerView Xaml. i named that property as selectedItem. however whenever i am trying to access that selected item property from orderview model. it is not working. can you plz tell what i am doing wrong? that selectedItem property in my customer view model should set everytime I select a new item in the list on customer view. it s not doing that either.

在此处输入图片说明 The ViewModel is tied to your View (the xaml & cs), it is not around the data.

For instance, MainWindow.xaml & cs should have a MainWindowViewModel.cs

You use one ViewModel to your view. I would suggest using the entity framework for your data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM