开发者

Implementing MVVM from scratch without using INotifyPropertyChange?

Why would MVVM obliged to be implemented with INotifyPropertyChange, IComm开发者_如何学JAVAand etc. since it seems so complicated MVVM - Presentation Model in Flex vs Presentation Model in Silverlight: advantages and disadvantages? ? Why not do it from scratch and do things simpler ?


Keep in mind that in Flex, they implement almost the exact same pattern as INotifyPropertyChanged. You need it in order to tell the UI to update. The only difference is that in Flex, you get the [Bindable] tag which implements the pattern for you. In Silverlight, you have to do it yourself. You can get help with implementing it, like with the "Property Weaver", but in BOTH cases, you have an event, and a pattern that looks like this (pseudocode):

var prop;
get: return prop
set: if prop == value return
     prop = value
     notify prop changed

As for commands, it has to do with the imperative vs declarative binding in Flex vs Silverlight. You don't need a command in Flex because you can simply call a method on your context. In Silverlight, it is declarative, so you need an object to bind to... you can't bind to methods since they are not objects. ICommand gives you that... but also adds messy plumbing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜