private void ExecuteNewQuestionCommand(Object parameter) { var view = new TecherFormAddAndEditQuestions(); var vm = new AddEditQuestionViewModel(); vm.Question = new Question(); vm.IsNewQuestion = true; vm.Window = view; view.DataContext = vm; var result = view.ShowDialog(); if (result.HasValue && result.Value) { vm.Question.Answers = new List <Answer>(vm.AnswerCollection); var questionid = DBDataSource.AddNewQuestion(vm.Question, NavigationHelper.CurrrentTest.Id); if (questionid > 0) { //Добавление вопроса в UI vm.Question.Id = questionid; QuestionCollection.Add(vm.Question); } } }