EventToCommandBehavior extends a .NET MAUI control without subclassing it, invoking a command when a specified UI event occurs and passing a binding-derived parameter. section 9.2 section 9.7
Complete a to-do item from a CheckBox
Install the CommunityToolkit.Maui NuGet package, initialize the toolkit in MauiProgram.cs, and import CommunityToolkit.Maui.Behaviors into MainPage.xaml. Add EventToCommandBehavior to the CheckBox, set EventName to CheckedChanged, bind Command to the page's CompleteTodoCommand, and use CommandParameter="{Binding .}" to pass the current to-do item to the database update method. section 9.2
Use the behavior when:
- A View must respond to a control event through ViewModel functionality. section 9.7
- The command needs the whole bound item or another binding-derived value rather than a bespoke event handler. section 9.2
