Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The way that I understand MVVM is this:</p> <p>1) Your UI is data-bound to your ViewModel. Your ViewModel in turn wraps your model, and converts it into a binding-friendly interface. Models might be persistence friendly, but persistence friendly models are not always UI friendly. The idea of the ViewModel is to bridge that gap and adapt the Model to something the UI can easily bind to.</p> <p>2) Your model can be any class- entity framework if you prefer, or plain classes (my preference). The only important thing is that it be able to notify your ViewModel when it's properties change. So I usually recommend that the model class either implement INotifyPropertyChanged or something similar.</p> <p>3) This is a design decision, up to you. Your data access layer should be separate from the Model, but should interact with the Model. See Single Responsibility Principle. Your Model only stores data.</p> <p>4) Business logic can be in the ViewModel, yes, or in controllers that coordinate one or more ViewModels.</p> <p>5) You typically want to create one ViewModel per type of UI element. This can get pretty fine-grained, especially when ViewModels contain other ViewModels. For instance, if you have a grid in your UI, you might have a ViewModel for the whole grid and then another ViewModel class for the rows themselves. It isn't unusual to have more ViewModels than Models- for instance, you might have a ViewModel for a grid row, and a different ViewModel for a Details view, but they might map to the same Model.</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload