/// <summary> /// Initializes a new instance of the <see cref="ChecklistQAMapViewModel"/> class. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="parentViewModel"> /// The parent view model. /// </param> /// <param name="validationHelper"> /// The checklist validation helper. /// </param> public ChecklistQAMapViewModel(ChecklistQAMapEdit model, IChecklistFieldQAMapViewModel parentViewModel, IChecklistValidationHelper validationHelper) { if (model == null) throw new ArgumentNullException("model"); if (parentViewModel == null) throw new ArgumentNullException("parentViewModel"); if (validationHelper == null) throw new ArgumentNullException("validationHelper"); Model = model; ParentViewModel = parentViewModel; ValidationHelper = validationHelper; _selectedQuestionField = FindQuestionField(); _answerField = FindAnswerField(); if (_answerField != null && CanIncludeInAvailableAnswerFields(_answerField)) _selectedAnswerField = _answerField; _questionFieldsChangedListener = new QuestionFieldsChangedListener(this, ParentViewModel) { OnEventAction = OnQuestionFieldsChanged, OnDetachAction = StaticQ }; ParentViewModel.QuestionFieldsChanged += _questionFieldsChangedListener.OnEvent; _answerFieldsChangedListener = new AnswerFieldsChangedListener(this, ParentViewModel) { OnEventAction = OnAnswerFieldsChanged, OnDetachAction = StaticA }; ParentViewModel.AnswerFieldsChanged += _answerFieldsChangedListener.OnEvent; }
private static void StaticA(AnswerFieldsChangedListener listener, IChecklistFieldQAMapViewModel source) { source.AnswerFieldsChanged -= listener.OnEvent; }
private static void StaticQ(QuestionFieldsChangedListener listener, IChecklistFieldQAMapViewModel source) { source.QuestionFieldsChanged -= listener.OnEvent; }
/// <summary> /// Creates a map view model. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="parentViewModel"> /// The parent view model. /// </param> /// <returns> /// The <see cref="IChecklistQAMapViewModel"/>. /// </returns> public IChecklistQAMapViewModel CreateViewModel(ChecklistQAMapEdit model, IChecklistFieldQAMapViewModel parentViewModel) { return new ChecklistQAMapViewModel(model, parentViewModel, ValidationHelper); }