liveBook · Manning

Behavior

As explained in .NET MAUI in Action

Behavior is the part of user-interface logic that specifies what interface elements do in response to conditions or interaction.

Behavior is the part of UI logic that defines what interface elements do in response to conditions or interaction. Layout determines where elements appear; behavior determines their actions. section 9.3.2

Use behaviors when an existing control needs additional interaction logic:

  • Attach functionality to a control without creating a subclass. section 9.2
  • Connect a control event to a command when the control has no bindable command property. section 9.2
  • Reuse an event-to-command behavior instead of writing a bespoke handler for one use case. section 9.2

Completing a to-do item

Attach an EventToCommandBehavior to a CheckBox, listen for CheckedChanged, invoke CompleteTodoCommand, and pass the bound to-do item as CommandParameter. The command can then update the item in the database. section 9.2

How .NET MAUI in Action covers it

How deep it goes
Defines behavior conceptually, then demonstrates attachment, event handling, command binding, and parameter passing.
Examples
Uses an animated label example and a to-do CheckBox that updates completion state through an event-to-command behavior.
What it assumes
Assumes controls, events, commands, binding contexts, and MVVM concepts while distinguishing behavior from layout.
What you can do after
Apply it via EventToCommandBehavior to extend controls and send event-triggered commands with custom parameters.
How it connects
Connects UI logic with layout, controls, MVVM, command binding, data binding, and dependency separation.

Also explained in

Compare how 4 books explain behavior →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.