Master Detail Page working on WP 8.1 but not 8.0

AurelioBenitezAurelioBenitez COMember
edited May 2015 in Xamarin.Forms

I'm working on the Windows Phone version of a multi platform application and I ran into this problem. The application displays a login screen if the user hasn't been authenticated using the following logic:

    public App()
    {
        // Register these services
        DependencyService.Register<MessageVisualizerService, MessageVisualizerService>();
        DependencyService.Register<NavigationService, NavigationService>();

        // is user logged in?
        if (validateInit())
        {
            MainPage = new MainPage(); // Here is the problem
        }
        else
        {
            MainPage = new LoginV();
        }

        CurrentPage = (Page) MainPage;
    }

The login page is displayed fine on both WP 8.0 and 8.1 but when redirecting the user to the main page or setting it as MainPage I'm getting a TargetInvocationException

The weird thing is that this only happens when running the app as Windows Phone 8.0, as 8.1 it shows the Main Page correctly.

Here's the code for the Main Page class:

public class MainPage : MasterDetailPage
{
    public MainPage()
    {
        Master = new NavigationPage(new MenuV()) { Title = "MENU", Icon = "", BarBackgroundColor = Color.FromHex("#D19401"), BarTextColor = Color.White };

        Detail = new NavigationPage(new TanquesV(new TanquesVM())) { BarBackgroundColor = Color.FromHex("#D19401"), BarTextColor = Color.White };

        Master.Icon = Device.OS == TargetPlatform.iOS ? "slideout.png" : null;
        // Force the master page to be shown initially on the phone
        // or portrait mode on tablet.
        if (Device.Idiom == TargetIdiom.Tablet)
            MasterBehavior = MasterBehavior.SplitOnLandscape;
        else
            IsPresented = false;

        App.MenuPage = this;
    }
}

MainPage is being correctly initialized, the problem happens when I give it to Forms' navigation.

Sign In or Register to comment.