wpf - Force update of view on validation error using MVVM pattern -


I have a problem: I have some control over a form (a check box, a combo box, a slider, a text box)

. Their values ​​are bound to different properties of the visual model.
When a property of a visual model is a fixed value, I want the controls to be "OK" (An error message is displayed and they are set to a certain value (such as: Checkbox uncheck Occurs when the user tries to check, the slider is set to a fixed value, the second item in the chosen item list of the combo is selected). I did this like this (a simple example text box): this In the following:

  text box text = "{see binding model property, notification processing update = truth, updates resource resetter = property changes, validation, auditator = true, notifyOnValidationError = true}" /> In the visual model: The property is defined as such:  
  string _ViewModelProperty; public string viewproperty {get_ViewModelProperty;} set {{_ViewMo} DelProperty = value; OnPropertyChanged ("ViewModelProperty");}}  

and the functions of IDataErrorInfo Nwyn:

  string IDataErrorInfo.this [String propertyName] {get {string error = null; If (propertyName == "ViewModelProperty") {If (ViewModelProperty! = "FixedValue") {error = DisplayMessage ("You can set just a fixed price here"); ViewModelProperty = "Fixed Price"; }} Return error; }}  

This works well for the check box, but for all other controls, it works like this: the user sets the "wrong" value, the error message And then, instead of updating control with fixed value, the wrong value is still displayed (this is no longer synchronized with the visual model).

I can not understand the value of control.

Thank you in advance.

You can tie the IsEnabled properties to control that you fix a set of properties on ViewModel Want to do this, like CanUserChangeSlider

  & lt; Slider IsEnabled = {Binding CanUserChangeSlider} ... />  

Then in the setter for the Campobox bass property:

  set {// Store support / backing / raisePropertyChanged in the backing store (value == true) {This.CanUserChangeSlider = false; // Fixed property constituted for a fixed value at the fixed value // combobox constitutes a fixed value}}  

Comments