开发者

Caliburn.Micro - is it possible to validate on exceptions with convention-based bindings?

开发者 https://www.devze.com 2023-01-26 20:05 出处:网络
I need to validate on exceptions when doing binding. Is this possible using Caliburn.Micro? Right now I have code that looks like

I need to validate on exceptions when doing binding. Is this possible using Caliburn.Micro?

Right now I have code that looks like

<TextBox x:Name="FirstName" />

But I get no validation on exceptions. If I change it to

<TextBox Text="{Binding FirstName, Mode=TwoWay, Validate开发者_JS百科sOnExceptions=True}" />

Then I get proper validation, but lose the nice convention-based binding. Any ideas?


Yes. Absolutely. To do this, you must replace ConventionManager.ApplyValidation with your own validation check and application code. You would do this in the Configure method of your bootstrapper so that it would be prepared for use by the framework. You might have something like this:

ConventionManager.ApplyValidation = (binding, viewModelType, property) => {      
   binding.ValidatesOnExceptions = true; 
};
0

精彩评论

暂无评论...
验证码 换一张
取 消