MVVM

View ↔ ViewModel ↔ Model: el ViewModel expone estado bindable y comandos.

Contexto

Apps con binding declarativo (WPF, MAUI, Avalonia, Blazor).

Solución

La View se enlaza por binding al ViewModel, que expone propiedades observables y ICommands. El Model es el dominio.

public class OrderViewModel : INotifyPropertyChanged
{
    private string _customer = "";
    public string Customer { get => _customer; set { _customer = value; OnChange(); } }

    public ICommand SaveCommand { get; }
    public OrderViewModel(IOrderService svc) =>
        SaveCommand = new RelayCommand(async () => await svc.SaveAsync(new Order(Customer)));

    public event PropertyChangedEventHandler? PropertyChanged;
    private void OnChange([CallerMemberName] string? n = null) =>
        PropertyChanged?.Invoke(this, new(n));
}
Tradeoffs
Pro Contra
Separación clara de responsabilidades Boilerplate de notify
Testeable sin levantar UI Bindings difíciles de depurar

#architecture #ui #wpf #maui