liveBook · Manning

Handler mapping

As explained in .NET MAUI in Action

A handler mapping is a customization definition that associates a view property or other key with logic for modifying its platform-specific handler.

A handler mapping connects a .NET MAUI view property or another key to logic that changes the view’s platform-specific handler. Handlers bridge cross-platform controls and native views, so mappings provide finer-grained control when the shared abstraction is not enough. section 11.3.1

Choose a mapper method according to how the customization relates to the defaults:

  • Use PrependToMapping for a new mapping that should run before the default mappings without overriding them. section 11.3.2
  • Use ModifyMapping to change an existing mapping, supplying its existing dictionary key. section 11.3.2
  • Use AppendToMapping for most customizations when the custom logic should run after defaults and take precedence. section 11.3.2

Removing an Entry border

An Entry handler mapping can append a customization under a key such as RemoveBorder. Its Action receives the handler instance and corresponding view, allowing platform-specific appearance changes. Mappings commonly live in MauiProgram startup logic or platform folders. section 11.3.2

Figure 11.11 Cross-platform controls are described by interfaces, and virtual views implement them as controls in the .NET MAUI UI layer. Handlers map the abstractions to platform-specific implementations.

Trace how interfaces and virtual views become platform-specific controls through handlers, the layer where mappings apply. section 11.3.1

How .NET MAUI in Action covers it

How deep it goes
Explains handler architecture and three mapper methods, then demonstrates placement and callback parameters without detailing platform implementations.
Examples
Uses Button BackgroundColor, a custom stepper, and an Entry RemoveBorder mapping to illustrate handler customization.
What it assumes
Assumes familiarity with .NET MAUI controls and properties while establishing handlers, virtual views, and native views.
What you can do after
Apply it via .NET MAUI mapper methods to customize existing controls and access platform-specific behavior.
How it connects
Connects handlers with virtual views, native views, mapper dictionaries, cross-platform controls, and platform-specific implementations.

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.