Advertisement
Intermediate .NET MAUI, Platform Integration & Handlers

How do you customize a control on a single platform using a handler?

Short answer

Use PropertyMapper customization scoped by checking the view instance, or subclass the handler for that control and register it. AppendToMapping adds behavior after the default; ModifyMapping replaces a specific property's mapping. Guard native calls with platform #if.

Save .NET MAUI mock interview
Advertisement
AModel answer
Use PropertyMapper customization scoped by checking the view instance, or subclass the handler for that control and register it. AppendToMapping adds behavior after the default; ModifyMapping replaces a specific property's mapping. Guard native calls with platform #if.
#if IOS
Microsoft.Maui.Handlers.SwitchHandler.Mapper.AppendToMapping(
    "Tint", (h, v) => h.PlatformView.OnTintColor =
        UIKit.UIColor.SystemGreenColor);
#endif
Real-world example
Product design wants iOS switches tinted brand-green; a single iOS-guarded mapper achieves it without touching Android.
Likely follow-ups
  • AppendToMapping vs ModifyMapping? | How do you scope to one control instance?
Related topics