开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜