views:

574

answers:

0

Hi,

I want to implement a view which contains a datagrid. When entering oder editing data a cell should provide a dropdownlist (or autocompletebox not sure yet). But I want to do it MVVM style... From the MVVM perspective I have a ListViewModel and a RowViewModel. And the ListViewModel contains a ObservableCollection Rows. My RowViewModel contains some properties which needs to be displayed in the datagrid as well as some Commands to remove or add new items (RowViewModels) to the grid. This is all working excellent with Prism Commanding and the Eventaggregator.

In the View I bind my ItemsSource of the datagrid to my collection of Rows. When I edit one row I want to display now my DropDownList in the cell which is bound to a Collection of let's say Customers. Where should I put the collection of customers? If I put it in the RowViewModel it gets populated on every instance of RowViewModel and in the worst case it pulls out the data on every creation... Or I would but it into the ListViewModel but then the DataContext of the datagrid cannot reach it since datagrids itemssourece is bound to the rows... This would be for me the place to put it...what do you guys think?