EntryHandler with PlaceHolder Text above in .Net MAUI

Viewed 65

How to Display Entry Control with PlaceHolder Text in MAUI.

I need to write a EntryHandler which would look like the below Image (Last Name* is the placeholder text)

PlaceHolder Text Above

I have written a entry handler with out the border which is looking like below, the problem with this is as the user starts typing the placeholder text hides

PlaceHolder vanish

 public class BorderlessEntry : Entry
    {
    }




  public App(AppShell page)
  {
    InitializeComponent();
   Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping(nameof(BorderlessEntry), (handler, view) =>
    {

        if (view is BorderlessEntry)
        {
        #if __ANDROID__
         handler.PlatformView.SetBackgroundColor(Microsoft.Maui.Graphics.Colors.Transparent.ToAndroid());
            handler.PlatformView.Hint = view.Placeholder;
        
          #elif __IOS__
            handler.PlatformView.BackgroundColor = Microsoft.Maui.Graphics.Colors.Transparent;
            handler.PlatformView.Layer.BackgroundColor = Microsoft.Maui.Graphics.Colors.Transparent;
            handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;
         #endif

        }
    });
}

I have been able to achieve the same in Xamarin Forms using MaterialEntryRenderer but the same is not supported in .net Maui

Any help is appreciated!

0 Answers
Related