开发者

How to implement Actions for observableCollections in Silverlight?

开发者 https://www.devze.com 2023-02-22 23:48 出处:网络
Im using MVVM. I am implementing my data as OberservableCollections in Model, and I want the ViewModel to listen to and update any changes in the OberservableCollections of data in Model.

Im using MVVM.

I am implementing my data as OberservableCollections in Model, and I want the ViewModel to listen to and update any changes in the OberservableCollections of data in Model.

I know you have to implement some Actions, e.g. inset, add, etc in ViewModel. But I can not find an开发者_开发问答y tutorial on it, can someone please provide some ideas, thanks :)


Since you are new to the MVVM pattern, read this post by Jeremy Likness, a Silverlight MVP. He gives basic examples of ViewModels, views, models, binding, commanding, etc.

As far as passing the model objects to the ViewModel, that all depends on where the model objects are coming from. For example, in most LOB applications, you will get data from the server via WCF, which introduces a layer of complexity to the pattern and the implementation.

If instead you mean "how does my ViewModel get notified when the user changes some data on the view", then that notification comes from your ViewModel implementing INotifyPropertyChanged, and your View binding to the properties exposed by your ViewModel. I think reading Jeremy's blog post will clear a lot of this up for you.

0

精彩评论

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

关注公众号