I recently started learning wpf and am trying to use mvvm.
I understand that in mvvm neither a view nor a model should know that there is another.
What I'm trying to do is display a list of clients on the screen. But if I encode viewModel as below. which is similar to many examples that I see on the net, then I get code similar to this
class Customer
{
public String Name {get;set;}
public String Address {get;set;} }
}
class MainWindowViewModel
{
ObservableCollection<Customer> customers = new ObservableCollection<Customer>();
public ObservableCollection<Customer> Customer
{
get {return customers;}
}
public MainWindowViewModel()
{
customers.Add(cust1);
customers.Add(cust2);
}
}
Now, if I create an instance of my MainWindowViewModel and set it as the datacontext of my MainWindowView (my view), and I also bind the viewmodels Clients to the listBox, then the view will need a reference to the assembly containing my models.
So, my questions.
1) , MVVM, , .
2) CustomerViewModel MainWindowViewModel ObservableCollection CustomerViewModel
ObservableCollection . .