How to handle One View with multiple ViewModel and fire different Commands

Posted by Naresh on Stack Overflow See other posts from Stack Overflow or by Naresh
Published on 2010-03-11T05:04:26Z Indexed on 2010/03/11 5:08 UTC
Read the original article Hit count: 346

Hi All,

I have senario in which one view and view has binding with multiple ViewModel.

Eg. One View displaying Phone Detail and ViewModel as per bellow:

  • Phone basic features- PhoneViewModel,
  • Phone Price Detail- PhoneSubscriptionViewModel,
  • Phone Accessories- PhoneAccessoryViewModel
  • For general properties- PhoneDetailViewModel

I have placed View's general properties to PhoneViewModel.Now senario is like this:

By default View displays Phone Basic feaures which is bind with ObservationCollection of PhoneViewModel. My view have button - 'View Accessories', onclick of this button one popup screen- in my design I have display/hide Grid and bind it with ObservationCollection of PhoneAccessoryViewModel.

Now problem begins- Accessory List also have button 'View Detail' onclick I have to open one popup screen, here also I had placed one Grid and Visible/Hide it. I have bind 'ViewAccessoryDetailCommand' command to 'View Detail' button. And on command execution one function fires and set property which Visible the Popup screen.

Using such programming command fires, function calls but the property change not raises and so my view does not display popup.

Summary: One View--> ViewModel1-->Grid Bind view ViewModel2 -->Grid Have Button and Onclick display new Grid which binded with ViewModel3-this Command fires but property not raises.

I think there is some problem in my methodology, Please, give your suggetions.

© Stack Overflow or respective owner

Related posts about mvvm

Related posts about model-view-viewmodel