public AgreementFormView() { InitializeComponent(); _vm = new AgreementFormViewModel(); DataContext = _vm; DataGrid.ItemsSource = _vm.ClientList.ToList(); }
private void EditButton_Click(object sender, RoutedEventArgs e) { if (_vm.SelectAgreement != null) { AgreementFormViewModel vm = new AgreementFormViewModel(_vm.SelectAgreement) { IsNew = false }; AgreementFormView agreementForm = new AgreementFormView { DataContext = vm }; agreementForm.DataGrid.IsEnabled = false; agreementForm.ShowDialog(); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { AgreementFormViewModel vm = new AgreementFormViewModel(new Agreement()) { IsNew = true }; AgreementFormView agreementForm = new AgreementFormView { DataContext = vm }; agreementForm.ShowDialog(); var agreementList = _vm.AgreementList; if (agreementForm.DialogResult == true) { agreementList.Add(vm.Agreement); vm.AgreementSave(); } }