Current filter:
                                You should refresh the page.
                                  • Hi, we are trying to run some validation from within a view model, the idea is that the main window shouldn't be closed if something is not valid... currently we are trying using some validation rules and some custom service but calling 'DoValidate' doesn't seem to work (there are some 'WinForms' related questions that seem to set 'IsModified = true' but that doesn't seem to exist in wpf)

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,
                                TextEdit's DoValidate method launches TextEdit's validation logic - the Validate event. A binding with validation rules is the standard WPF approach that is used at the binding level. So, the DoValidate method doesn't affect it.
                                To accomplish this task, you can use common approaches like the one described in the Force validation on bound controls in WPF or Accessing WPF control validation rules from code thread.

                                Thanks,
                                Kirill

                                • Andrés Conesa 08.22.2019

                                  using ValidatesOnTargetUpdated="True" in the rule in xaml works but that makes the window have errors even before updating data, looks like calling UpdateSource / UpdateTarget on BindingExpression (property 'EditValueProperty') makes the control try to refresh its value (the get in the property is called) but looks like validation isn't called [no errors shown]...

                                • Andrey Marten (DevExpress Support) 08.23.2019

                                  Hello Andres,

                                  This validation behavior is controlled by the Binding mechanism and TextEdit cannot affect it. Therefore, you can search for suitable approaches on the Internet. My brief search gave these links:

                                  Hide WPF validation error when window is first loaded
                                  How can i stop validation on window load WPF ?!

                                  If you decide to change your implementation and use TextEdit's Validate event, you can try the approach that Ivan illustrated in this thread: T600013 - Validation: how to prevent validation when viewmodel is bound.

                                  Thanks,
                                  Andrey