Remove entry border for your .NET MAUI app

Today, I successfully upgraded my Chick and Paddy .NET MAUI sample to .NET8. It was a long wait because I failed to upgrade to .NET8 preview releases.

Things went well except the entry border which was supposed to be none in .NET6/7 as you might find the code snippet in this article.

After reading for a while, I found the comment in a GitHub issue and here is the way we need to remove the entry border.

Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoBorderEntry", (handler, view) =>
{
#if ANDROID
        handler.PlatformView.Background = null;
        handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
        handler.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Transparent);
#elif IOS || MACCATALYST
        handler.PlatformView.BackgroundColor = UIKit.UIColor.Clear;
        handler.PlatformView.Layer.BorderWidth = 0;
        handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
#elif WINDOWS
        handler.PlatformView.FontWeight = Microsoft.UI.Text.FontWeights.Thin;
#endif
});

Happy coding!