Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net 4.5 : Should I use IDataErrorInfo or INotifyDataErrorInfo?

Tags:

mvvm

wpf

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?

like image 470
Hussein Avatar asked Oct 16 '13 12:10

Hussein


1 Answers

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.

like image 157
Michael Edenfield Avatar answered Nov 18 '22 08:11

Michael Edenfield