So I've followed a YouTube video and the Microsoft docs on this but it still isn't working. I have a page with my custom renderer on it, which I've used the namespace for...
<local1:RoundedEntry Text="Test"/>
This comes from a .cs file
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
namespace TestApp
{
public class RoundedEntry : Entry
{
}
}
Then what exports to this file is this...
using Android.Content;
using TestApp;
using TestApp.Droid.CustomRenderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(RoundedEntry), typeof(RoundedEntryAndroid))]
namespace TestApp.Droid.CustomRenderers
{
public class RoundedEntryAndroid : EntryRenderer
{
public RoundedEntryAndroid(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.SetBackgroundColor(global::Android.Graphics.Color.LightGreen);
}
}
}
}
I've tried this and I've tried downloading the example Entry Custom Renderer from https://developer.xamarin.com/samples/xamarin-forms/customrenderers/entry/ but it still doesn't work. I get no errors or warnings, but the application won't load the page with the custom renderer on it, it will crash. I'm not sure why it is crashing, I've updated to the latest Xamarin.Forms through Nuget. Also, it works if I remove the <local1:RoundedEntry Text="Test"/>
Anyone know of a fix? Thanks!
Edit: It works when deploying it to a device but not in the LivePlayer or Forms Previewer. It is a bit annoying to not be able to see what I'm doing.