What problem does it solve?
Customizing how .NET MAUI controls render and behave on each platform is error-prone and easy to get wrong; this guide explains safe patterns for extending or replacing handler behavior without breaking framework defaults or leaking native resources. It highlights mapper selection pitfalls, lifecycle event management, and the partial-class pattern required for platform-specific native views.
Core Features & Use Cases
- Mapper methods & patterns: When to use AppendToMapping, PrependToMapping, and the risks of ModifyMapping.
- PropertyMapper vs CommandMapper: How to sync bindable properties versus one-off command actions.
- Handler lifecycle and safety: Subscribe/unsubscribe native events in HandlerChanged/HandlerChanging to avoid memory leaks and ensure identical partial-class names and namespaces across platforms.
- New handler checklist: Guidance on shared handler files, conditional PlatformView aliases, CreatePlatformView implementations per platform, and registering handlers via ConfigureMauiHandlers.
- Use case: Remove the border of an Entry control only for a BorderlessEntry subclass on Android while keeping default behavior on other controls and platforms.
Quick Start
Register a handler in MauiProgram.cs that appends a mapper to adjust the native view for a BorderlessEntry subclass and implement CreatePlatformView in each platform partial.