Back to results for “INotifyPropertyChanged”
.NET MAUI › Data Binding & MVVM

What is INotifyPropertyChanged and why is it required?

Intermediate

Answer

INotifyPropertyChanged defines the PropertyChanged event that a binding source raises when a property value changes, telling the UI to refresh. Without it, one-way and two-way bindings to view-model properties won't update the UI after the initial value. Each settable bound property must raise it.
public class MainViewModel : INotifyPropertyChanged
{
    string _name;
    public string Name
    {
        get => _name;
        set { _name = value;
              PropertyChanged?.Invoke(this,
                  new PropertyChangedEventArgs(nameof(Name))); }
    }
    public event PropertyChangedEventHandler PropertyChanged;
}
Real-world example A live-updating price label refreshes only because the view model raises PropertyChanged when the price field changes.

Common follow-ups: How does CommunityToolkit.Mvvm reduce this boilerplate? | Which binding modes need it?