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!
Subscribe to my newsletter
Read articles from Tuyến Vũ directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Tuyến Vũ
Tuyến Vũ
Tuyen is a very skilled C#.NET developer with many years of building large systems for banking, real estate and ecommerce. He is also very strong in mobile application development across different stacks like Flutter, ReactNative, Xamarin.Forms/.NET MAUI.