Search code examples
.netasp.net-corexamarinmaui

How can i create entry without under line using maui


create entry without under line using maui create entry without under line using maui create entry without under line using maui create entry without under line using maui create entry without under line using maui

 <Entry Placeholder="enter your name "/>

Solution

  • The implementation of entry without under line colors for each platform:

    On Android:

    It's needed to use handler in Android platform. You can add the following code in Platforms -> Android -> MainApplication.cs:

     protected override MauiApp CreateMauiApp()
     {
       Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("RemoveUnderLine", (r, v) =>
         {
             r.PlatformView.BackgroundTintList =
                 Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToAndroid());
         });
    
         return MauiProgram.CreateMauiApp();
     }
    

    On Windows:

    add the following code in Platforms -> Windows -> App.xaml:

    <maui:MauiWinUIApplication.Resources>
            <Thickness x:Key="TextControlBorderThemeThickness">0</Thickness>
            <Thickness x:Key="TextControlBorderThemeThicknessFocused">0</Thickness>
     </maui:MauiWinUIApplication.Resources>
    

    On iOS:

    On iOS platform, Entry does not have under line color by default.