Table of Contents
Model–View–ViewModel (MVVM) separates what a screen displays from the logic that prepares its state. The view binds to a view model’s properties and commands. The view model coordinates the screen’s behavior and calls the application’s model or services when it needs data or a business operation.

How MVVM works on a profile form
- View: Shows the name field, the Save button, and any loading or error messages. It binds those controls to properties and commands.
- View model: Exposes the draft name, whether the form is saving, the error state, and a save command. It updates those values as the save finishes or fails.
- Model and services: Represent the account data, enforce rules about valid names, and persist the change.
A two-way binding can update the draft name as the person edits it. A one-way binding can show an error message that only the view model sets. In WPF, the view model is often provided through DataContext. .NET MAUI uses BindingContext. A view can still use code-behind for visual behavior, such as putting focus into a field. See Microsoft’s MVVM guide for binding and command examples.

What is MVVM?
MVVM vs. MVC vs. MVP
| Pattern | Who handles input? | How the view gets updates |
|---|---|---|
| MVVM | View model commands and binding updates | The view observes or binds to the view model’s state. |
| MVC | A controller handles input or a request. | In a typical server-rendered MVC app, the controller selects a view and gives it data to render. |
| MVP | A presenter receives events from the view. | The presenter often calls an interface on a passive view to update it. |
These are common arrangements. Frameworks use variants of each pattern.
When MVVM earns its extra layer
MVVM is useful when a screen has state worth testing separately, such as validation, loading, save failures, and retries. You can test what the view model exposes after a save fails without opening the UI. If a screen only displays a few values and has little interaction, the extra binding and command code may add more work than it saves. The same separation of data, logic, and interface responsibilities can help you decide where each behavior belongs.
Reader Comments 0
Sign in with email or Google to join the discussion.