SuspendValidation = true;

Topics: Questions
Nov 17, 2014 at 12:42 PM
Hi

How do SuspendValidation works.
  • Do SuspendValidation only works for the viewmodels which calls it.
  • What happens with explicit calls of Validate();
Coordinator
Nov 17, 2014 at 12:44 PM
Yes, only only the (view) models you call it on.

See source to see how it is handled:

https://github.com/Catel/Catel/blob/develop/src/Catel.Core/Catel.Core.Shared/Data/ModelBase.validation.cs#L737
Nov 17, 2014 at 12:55 PM
Ok.

But there is also a property called SuspendValidationForAllModels.

So I can:

SuspendValidationForAllModels = true
//... Do a lot of things
SuspendValidationForAllModels = false

// now I need to validate all (view)models one time. ->
ValidateAllModels(true);

Is there any way to do this?
Coordinator
Nov 17, 2014 at 12:56 PM
If you have a ModelManager of some sort, you can query all the currently alive models. Then you can loop through them. Catel doesn't provide a list of currently alive models.
Nov 17, 2014 at 2:28 PM
Ok. One more question to the validation.

I have a service which loading my models. The models begin to valide if they are loaded. How to suspend the validation in the service?
Coordinator
Nov 19, 2014 at 10:18 AM
A property?