I'm trying to learn MVVMLight and I'm stuck at creating a new view for editing an object.
I have CustomersView
with CustomersViewModel
that display a datagrid with customers. On double click on DataGridRow, I open a CustomerView
that implements a CustomerViewModel
to edit the customer and I'm using this code in CustomersViewModel
:
var cv=new CustomerView();
var cvm=new CustomerViewModel();
cvm.IsEdit = true;
cvm.Customer = customer;
cv.DataContext = cvm;
cv.ShowDialog();
Is this a bad approach? What is the best way to create a view, instantiating the view model with some parameters?