Reputation: 65
I am fairly new to WPF/MVVM but I have read through a lot of tutorials and done some small projects so have gained an elementary understanding.
My problem:
I have a Model class which holds a collection of data. My main View must display several of Models' data on a DataGrid. My current approach is making a DataGrid in the Model's View by defining a Datatemplate with a DataGrid whose ItemsSource is the Model's Collection.
This approach sort of works but it creates a Datagrid for each Model. Does anyone know of a good way to have only a single DataGrid?
Upvotes: 0
Views: 108
Reputation: 50692
If the view should display a single grid you might want to make a ViewModel with a single collection and fill the collection from several Model collections.
That is what the ViewModel is for.
Upvotes: 1