You see a better way, how can I call / compose a dialog from a controller / ViewModel from it and set the DocumentViewModel as a DataContext dialog?
The problem is that I cannot use the first approach of the approach in DocumentDetailWindow and its UserControl affiliation, because I cannot set Model in the Document DocumentModel Document Property in XAML
How would you solve this scenario? Make Dialog properly bound, call the dialog and return the data from it to LessonPlannerController so that the new document can be saved in the database and added to the associated ObservableCollection of documents so that the GUI is updated with another document.
LessonPlannerController / ViewModel:
private void OnAddDocument()
{
DocumentDetailWindowaddDocumentWindow = new DocumentDetailWindow();
DocumentViewModeldocumentViewModel = new DocumentViewModel();
documentViewModel.Document = new Document();
documentViewModel.Repository = new LessonPlannerRepository();
documentViewModel.SaveDocumentDelegate += new Action<Document>(OnSaveDocument);
addDocumentWindow.DataContext = documentViewModel;
addDocumentWindow.ShowDialog();
}
UPDATE:
I even thought about not doing this => documentViewModel.Document = new Document (); because why do I need a model in in the ViewModel when I can do this:
In REALITY, these properties have the NotifyPropertyChange ... public string DocumentName {get; set;} public string Keywords {get; set;}
Document DocumentViewModel, Save, LessonPlannerControl ..... , View first , . ViewModel.
? ocumentViewModel.Document = new Document();
2 DocumentViewModel. Hm... , ?...