Binding modes and the INotifyPropertyChanged interface
In Chapter 1, What Is the MVVM Design Pattern, we already discussed how data can flow:
- One-way: From ViewModel to View
- One-way-to-source: From View to ViewModel
- One-time: Only once from ViewModel to View
- Two-way: From ViewModel to View and from View to ViewModel
Now, let’s take a look at how this is handled in .NET MAUI.
Binding modes in .NET MAUI
.NET MAUI supports all of these data flows, represented through the Microsoft.Maui.Controls.BindingMode
enum: OneWay
, OneWayToSource
, OneTime
and TwoWay
. There is in fact a fifth value as well: Default
. Remember when we talked about bindable properties earlier in this chapter? When creating a bindable property, there are some optional values we can set. One of those optional parameters is defaultBindingMode
. This allows us to set a default binding mode on a bindable property. On Entry
, for example, it makes sense to have the default binding mode...