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
?
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
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 theErrorsChanged
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
overIDataErrorInfo
, 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.