dotMorten / MauiEx

A set of .NET MAUI controls
Apache License 2.0
225 stars 55 forks source link

Custom renderer not loading #84

Closed eko94 closed 4 years ago

eko94 commented 4 years ago

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

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);
        }
    }
}