private void btnAddMonograph_Click(object sender, RoutedEventArgs e) { var view = new MonographView(); var monographViewModel = new MonographViewModel() { Researcher = (ResearcherViewModel)DataContext, Mode = Mode.Add }; view.DataContext = monographViewModel; view.ShowDialog(); }
public AddMonograph(bool isEdit, MonographViewModel monograph) { InitializeComponent(); _isEdit = isEdit; if (isEdit && monograph == null) { throw new ArgumentNullException(nameof(monograph), "Обязательно нужен исследователь"); } Monograph = monograph ?? new MonographViewModel(); _model = _isEdit ? Monograph.Clone() : Monograph; DataContext = Monograph; AddButton.Content = _isEdit ? "Сохранить" : "Добавить"; this.Title = _isEdit ? "Изменить монографию" : "Добавить монографию"; ReleaseYearNUD.Value = DateTime.Now.Year; }