Force validation on bound controls in WPF -


I have a WPF dialog with some text box on it. Text boxes are bound to my business object and WPF validation rules are enclosed.

The problem is that users can actually click on the 'OK' button and in fact can stop the dialog without entering the data in the text box Verification rules never fire, because user notifications Do not even try to enter in the text box.

Is it possible to emphasize verification checks and to determine whether some verification rules have been broken?

It may be able to do this when the user tries to close the dialog and prevents him from breaking any validation rule.

Thank you.

We also have this problem in our application. Verification only occurs when binding is updated, you will need to manually update it: We do this in the event of a window:

  Public Zero Window_loaded (Object Sender, Routing Avenger, AGE E) { // We set bindings manually, so we start verification in the beginning txtName.GetBindingExpression (TextBox.TextProperty) .UpdateSource (); TxtCode.GetBindingExpression (TextBox.TextProperty) .UpdateSource (); }  

This error will reveal the template (red setting), and set the property, which we have triggered the OK button to disable:

  & Lt; Button x: name = "btnok" content = "ok" isdefault = "true" click = "btnOK_Click" & gt; & Lt; Button.Style & gt; & Lt; Style TargetType = "{x: type button}" & gt; & Lt; Setter property = "iced" value = "wrong" /> & Lt; Style.Triggers & gt; & Lt ;! - Required to validate controls - by pressing OK - & gt; & Lt; MultiDataTrigger & gt; & Lt; MultiDataTrigger.Conditions & gt; & Lt; Condition binding = "{binding element name = txtName, path = (validation .hesError)}" value = "wrong" /> & Lt; Condition binding = "{binding element name = txtCode, path = (validation .hesError)}" value = "wrong" /> & Lt; /MultiDataTrigger.Conditions> & Lt; Setter property = "iced" value = "true" /> & Lt; / MultiDataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /Button.Style> & Lt; / Button & gt;  

Comments