Advertisement
Intermediate .NET MAUI, Fundamentals & Architecture

What is the handler architecture in MAUI?

Short answer

Handlers map a cross-platform virtual control (e.g., Button) to its native counterpart (Android AppCompatButton, iOS UIButton, WinUI Button). Each handler exposes a property mapper and command mapper that translate cross-platform properties into native calls.

Save .NET MAUI mock interview
Advertisement
AModel answer
Handlers map a cross-platform virtual control (e.g., Button) to its native counterpart (Android AppCompatButton, iOS UIButton, WinUI Button). Each handler exposes a property mapper and command mapper that translate cross-platform properties into native calls. Handlers are decoupled from the control via the IView interface, making them lighter and more testable than Xamarin's renderers.
Microsoft.Maui.Handlers.ButtonHandler.Mapper.AppendToMapping(
    "MyCustomization", (handler, view) =>
    {
#if ANDROID
        handler.PlatformView.SetAllCaps(false);
#endif
    });
Real-world example
A team removes the default all-caps styling on Android buttons app-wide by appending one line to the ButtonHandler mapper, without subclassing anything.
Likely follow-ups
  • How do you customize a handler? | What is a property mapper?
Related topics