.Net 4.5 : Should I use IDataErrorInfo or INotifyDataErrorInfo?

后端 未结 1 454
小蘑菇
小蘑菇 2021-01-30 21:14

I used to use IDataErrorInfo in my MVVM/WPF applications. Now after INotifyDataErrorInfo is available in .Net 4.5 is it better to replace IDataEr

相关标签:
1条回答
  • 2021-01-30 21:30

    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.

    0 讨论(0)
提交回复
热议问题