Freigeben über


MVVM with RIA Services

MVVM without RIA:

· MVVM relies on the concept that View (XAML) will not contact your Model directly.

· View will contact Model via ViewModel classes.

· ViewModel talks with View using Data Binding and Commanding in XAML based applications.

· ViewModel talks with Model via web service communication in case of Silverlight when we don’t use RIA Service.

 

clip_image001[6]

 

 

MVVM with RIA:

 

· RIA Service abstracts the web service layer from developer’s perspective and presents on client an identical set of classes that we have in model on server.

· This simply means that under normal MVVM scenario we just change the communication between ViewModel and Model to go via the auto generated model classes on client side instead of explicitly calling web services (though internally it is still WCF communication).

· In my opinion, this should not pose any problems to the MVVM pattern given that we keep the communication link same as above.

 

clip_image002[6]

 

Cautions/DON’Ts:

 

· We should never attach the auto generated client model classes of RIA with View directly. This link of View to Model should happen via ViewModel only. In a nutshell, these auto-generated model classes should never be considered as ViewModel.

 

· We also have the availability of some RIA controls like DomainDataSource (in XAML). In case of MVVM we should NEVER use any such RIA controls in XAML since they break the very pillar of MVVM by contacting auto generated client side model of RIA directly (which is same as above point).

 

Rahul Gangwar

Comments

  • Anonymous
    October 07, 2010
    Rahul this is nice and gives a quick overview as to how this can be leveraged. Good work, Keep it up!!!!!!! Your blog is in my reading list and am following it closely :-)

  • Anonymous
    October 08, 2010
    Thanks Yogi. This is sweet.