Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
336 views
in Technique[技术] by (71.8m points)

wpf - .Net 4.5 : Should I use IDataErrorInfo or INotifyDataErrorInfo?

I used to use IDataErrorInfo in my MVVM/WPF applications. Now after INotifyDataErrorInfo is available in .Net 4.5 is it better to replace IDataErrorInfo or continue the old way using IDataErrorInfo?

question from:https://stackoverflow.com/questions/19402840/net-4-5-should-i-use-idataerrorinfo-or-inotifydataerrorinfo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are a number of improvements in INotifyDataErrorInfo (in particular, it's support for multiple, dynamically changing error messages per object/property) that make it superior to the previous interface. But the biggest difference is that it's asynchronous. You now have to fire the ErrorsChanged event whenever the error state changes.

If you are implementing an application in .NET 4.5 that targets devices running Windows 8, you should strongly consider using the new interface. Asynchronous-style programming is the "intended model" for such applications, particularly if you include RT-devices. It's not that much more complex to implement INotifyDataErrorInfo over IDataErrorInfo, so there's not really a downside.

That doesn't mean you should go retrofit all your existing applications, though; again, it depends on your target. If you're trying to upgrade an existing application to be RT-compatible, you should probably swap in the new error handling code. Otherwise, no need to change what works.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...