Advertisement
Advanced .NET MAUI, Controls & Views

How do you customize a control's native appearance without a full custom control?

Short answer

Use handler mappers to reach into the platform view. AppendToMapping runs after the default mapping so you can tweak native properties per platform, guarded by #if. This avoids subclassing and keeps customization centralized in MauiProgram or a startup routine.

Save .NET MAUI mock interview
Advertisement
AModel answer
Use handler mappers to reach into the platform view. AppendToMapping runs after the default mapping so you can tweak native properties per platform, guarded by #if. This avoids subclassing and keeps customization centralized in MauiProgram or a startup routine.
EntryHandler.Mapper.AppendToMapping("NoUnderline", (handler, view) =>
{
#if ANDROID
    handler.PlatformView.BackgroundTintList =
        Android.Content.Res.ColorStateList.ValueOf(
            Android.Graphics.Color.Transparent);
#endif
});
Real-world example
A design team removes the Android Entry underline app-wide with one mapper customization instead of a custom renderer.
Likely follow-ups
  • When is a mapper better than a custom control? | How do you scope a mapper to one control?
Related topics