Reputation: 5420
Which one is the better solution to hold my data or does it depends on some conditions?
sample situation 1:
you need to display a list of data which can be modified in an new window after selection.
sample situation 2:
you need to display a list of data which can be modified in this list.
Upvotes: 8
Views: 2658
Reputation: 1697
I would say go with ObservableCollection<Model>
since it is something that you can bind directly to the List or datagrid.
For Sample Situation 1 : Select a Model and then set the data context of the new Window to that Model.
For Sample Situation 2 : In place editing of the datagrid with 2 way binding.
The ObservableCollection can be inside a ViewModel. Something like the one shown below.
public class MyViewModel
{
public ObservableCollection<Model> ListOfItems { get; set;}
}
Upvotes: 0
Reputation: 56459
As you're using MVVM, you should be going with ObservableCollection<ViewModel>
.
The Model should be separated from the View by means of the ViewModel.
Upvotes: 10