2

MVC framework: What I understand ViewModel in MVC is that collection of different model in a single model and that pass in the View, as we can pass one model to the view.

MVVM framework: In MVVM framework ViewModel will have presentation logic along with object of models, but this is not combination of model objects basically ViewModel use for events and notifications.

please give your thought.

Afazal
  • 542
  • 5
  • 9
  • A view model is not a _collection of different model in a single model_ Refer [What is ViewModel in MVC?](http://stackoverflow.com/questions/11064316/what-is-viewmodel-in-mvc) –  Sep 01 '15 at 12:28
  • 3
    possible duplicate: http://stackoverflow.com/questions/1939403/mvvm-viewmodel-vs-mvc-viewmodel?rq=1 – Piotr Czarnecki Sep 01 '15 at 12:30
  • MVC does not have a ViewModel, it has a Model, a View and a Controller – Glen Thomas Sep 01 '15 at 12:37

1 Answers1

1

Your observation is correct.

The ViewModel is passive in MVC while in MVVM it is active. In MVC, by default what we call ViewModel might be called simply Model.

Similarities:

  • the ViewModels, in both MVC and MVVM, provide data to the view so the view can display it nicely to the user
  • the ViewModel can aggregate sub-ViewModels but in the end there is one instance served to the view via a property (called Model in MVC and DataContext in MVVM)

Differences:

  • The ViewModel in MVVM offers, via ICommand implementations, actions for the user which can be enabled/disabled dynamically based on the values of other properties, which usually implement INotifyPropertyChanged
  • Data binding exists in both worlds but in MVC it is only 'OneTime' whereas in MVVM it can be 'OneTime', 'OneWay', 'TwoWay' or even 'OneWayToSource'
Dean Kuga
  • 11,878
  • 8
  • 54
  • 108
Andrei Rînea
  • 20,288
  • 17
  • 117
  • 166