开发者

What aspects/practices of WPF could be most useful outside of WPF?

开发者 https://www.devze.com 2023-01-10 16:46 出处:网络
What aspects and practices specific to WPF could be most useful (and not inconceivable to implement) in 开发者_C百科non-WPF GUI programming?I was introduced to the command pattern by learning the WPF

What aspects and practices specific to WPF could be most useful (and not inconceivable to implement) in 开发者_C百科non-WPF GUI programming?


I was introduced to the command pattern by learning the WPF commands. It forms the basis for the UI - code separation, which I believe should be utilized in other applications.


Updating of the view via events. Databinding magic happens due to INotifyPropertyChanged and INotifyCollectionChanged. Writing a non-WPF app that, rather than blocking on queries, updated its data through either these interfaces or a custom one is a solid practice that can help ensure good separation of responsibilities as well as testability.


MVVM or Model-View-ViewModel is a fantastic design pattern and one that I hope will become widespread on the internet.

On that, have a look at Steve Sanderson's Knockout UI javascript library.


Ok, it's not entirely specific to WPF (it is used in silverlight as well), but I find IDataErrorInfo to be extremely useful outside of WPF / Silverlight. For my ASP.NET MVC applications my ViewModels implement IDataErrorInfo (for complex validations that are uncomfortable to solve using the validation attributes - such as if field A has a particular value, and field B has a particular value, then C can only be in a small subset of values). Then I have an extension method on my controllers that adds those data validation errors to the ModelState. Works like a charm.

0

精彩评论

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