dotMorten / MauiEx

A set of .NET MAUI controls

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom renderer not loading

eko94 opened this issue · comments

commented

Description

I'm trying to create a custom renderer for this plugin on Android but CustomRenderer file is not loading, therefore not changing the control.

Expected Behavior

Custom renderer loading and taking effects on changes made.

Actual Behavior

Custom renderer not loading and not taking any effect on changes made.

Basic Information

  • Version with issue: 1.1.1
  • Last known good version: I don't know
  • IDE: Visual Studio 16.5.3
  • Platform Target Frameworks:
    • Android: 9.0 (API 28)
  • Affected Devices: Emulator

Reproduction Code

The next code is in Android project:

using Xamarin.Forms.Platform.Android;
using dotMorten.Xamarin.Forms.Platform.Android;
using NativeAutoSuggestBox = dotMorten.Xamarin.Forms.Platform.Android.AndroidAutoSuggestBox;

[assembly: ExportRenderer(typeof(Test.Droid.Renderers.CustomAutoSuggestBox), typeof(Test.Droid.Renderers.CustomAutoSuggestBoxRenderer))]
namespace Test.Droid.Renderers
{
    public class CustomAutoSuggestBox : AutoSuggestBox { }

    public class CustomAutoSuggestBoxRenderer : AutoSuggestBoxRenderer
    {
        public CustomAutoSuggestBoxRenderer(global::Android.Content.Context context) : base(context) { }
 
        protected override void OnElementChanged(ElementChangedEventArgs<AutoSuggestBox> e)
        {
            base.OnElementChanged(e);

            GradientDrawable gd = new GradientDrawable();
            gd.SetColor(global::Android.Graphics.Color.Red);
            this.Control.SetBackground(gd);
        }
    }
}