You can
see an explanation of the MVVM Pattern in the Windows environment:
In the Model-View-ViewModel design pattern, an app is composed of three general components.
- Model: This represents the data model that your
app consumes. For example, in a picture sharing app, this layer might
represent the set of pictures available on a device and the API used to
read and write to the picture library.
- View: An app typically is composed of multiple
pages of UI. Each page shown to the user is a view in MVVM terminology.
The view is the XAML code used to define and style what the user sees.
The data from the model is displayed to the user, and it’s the job of
the ViewModel to feed the UI this data based on the current state of the
app. For example, in a picture sharing app, the views would be the UI
that show the user the list of albums on the device, the pictures in an
album, and perhaps another that shows the user a particular picture.
- ViewModel: The ViewModel ties the data model, or
simply the model, to the UI, or views, of the app. It contains the
logic with which to manage the data from the model and exposes the data
as a set of properties to which the XAML UI, or views, can bind. For
example, in a picture sharing app, the ViewModel would expose a list of
albums, and for each album expose a list of pictures. The UI is agnostic
of where the pictures come from and how they are retrieved. It simply
knows of a set of pictures as exposed by the ViewModel and shows them to
the user.
No comments:
Post a Comment