开发者

WPF Validation with ContentPresenter

开发者 https://www.devze.com 2022-12-27 17:03 出处:网络
I have a WPF user control which needs to validate some fields.It is bound to a class implementing IDataErrorInfo.

I have a WPF user control which needs to validate some fields. It is bound to a class implementing IDataErrorInfo.

When I set the user control as the content of my ContentPresenter in another, already open, window, I can see validation occurring, and error messages being returned, however, I don't get any validation adorner - e.g. the default red outline.

If I enter the field and leave it (triggering re-validation) the validation adorner appears.

Also, if I show the user control in it's own window it shows the validation adorner immediately.

(I'm using Caliburn IResults to do this underneath, e.g. Show.Dialog<VM>(); but I suspect this isn't related)

Can anyone offer any suggestion why the validation adorners aren't appearing immediately. (I had guessed animation on my 开发者_运维问答ContentPresenter ContentChanged, however, I have removed this and still experience the problem.

thanks, Chris


This is a known bug that exists in .NET 3.5. You may be able to implement a workaround, however if it is feasible, I would recommend upgrading to .NET 4 as this will take care of your issue with validation.

0

精彩评论

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