I am trying to write a custom renderer for the MasterDetailPage in Xamarin.Forms (v. 2.3.3.175). I need to adjust the default Master width which is way too large compared to its content.
Unfortunately I get a "System.NullReferenceException" as soon as the custom renderer class is created. I have cleaned everything and I still get the error. It seems that simply deriving my class from MasterDetailRenderer is causing the issue.
For the sake of testing I have stripped my custom renderer down to as follows:
[assembly: Xamarin.Forms.ExportRenderer(typeof(Xamarin.Forms.ExMasterDetailPage), typeof(ExMasterDetailRenderer))]
namespace MDPageTest.Droid.Renderers {
public class ExMasterDetailRenderer : MasterDetailRenderer
{ }
}
Nothing else! Still the error occurs. Either commenting the attribute line (hence disabling the custom renderer) or removing the class derivation solves the issue and the app starts without any other error.
Is anybody else experiencing such an issue? Any clue on how to fix it ?
Thank you in advance. Cheers,
M.
The cause for this is likely that your
MainActivity
inherits fromFormsAppCompatActivity
instead ofFormsApplicationActivity
. You should be able to resolve this by making your custom renderer inherit fromMasterDetailPageRenderer
from theXamarin.Forms.Platform.Android.AppCompat
namespace.