Bug 59878 - Using a custom renderer for NavigationPage results in InvalidCastException when calling base.OnElementChanged()
Summary: Using a custom renderer for NavigationPage results in InvalidCastException wh...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-10-01 06:45 UTC by Nicholas Bauer
Modified: 2017-10-03 21:25 UTC (History)
2 users (show)

See Also:
Tags: custom renderer, navigationpage, ac
Is this bug a regression?: ---
Last known good build:


Description Nicholas Bauer 2017-10-01 06:45:31 UTC
Using this custom renderer causes InvalidCastException inside the base class OnElementChanged function:

using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using MyApp.Droid.Renderers;

[assembly: ExportRenderer(typeof(NavigationPage), typeof(NavigationPageRenderer))]
namespace MyApp.Droid.Renderers
    public class NavigationPageRenderer : NavigationRenderer
        protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)

It may or may not matter, but in my case, the NavigationPage in question is being used inside a MasterDetailPage Detail pane.

This bug appears to be documented elsewhere:


Comment 1 Nicholas Bauer 2017-10-03 21:25:17 UTC
Ah... I figured out the problem.

It's AppCompat vs. regular. Which I had no idea was a thing until encountering this.

It would be really useful to have an informative exception message to direct developers to the correct classes.

Note You need to log in before you can comment on or make changes to this bug.