Hello,
You need to register this custom renderer in the MauiProgram.cs
.
1.Enable the UseMauiCompatibility
2.Add AddCompatibilityRenderer
for android platform and iOS platform.
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.UseMauiCompatibility()
.ConfigureMauiHandlers(handlers => {
#if __ANDROID__
handlers.AddCompatibilityRenderer(typeof(CustomEntry), typeof(MauiApp4.Platforms.Android.CustomEntryRenderer));
#elif IOS
handlers.AddCompatibilityRenderer(typeof(CustomEntry), typeof(MauiApp4.Platforms.iOS.CustomEntryRenderer));
#endif
});
By the way,this.Control.SetBackgroundDrawable(gd);
is deprecated, you can set it by this.Control.Background = gd;
directly in the CustomEntryRenderer for android platform.
As note, custom renderer is deprecated way, if you want to custom control in MAUI, you can try to use Handler,
Here is a document about custom entry with handler.
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.