Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 81910

MVVMCross Forms + MasterDetail Android error

$
0
0

I'm trying to implement Master Detail Page and MVVMCross,
it works fine on ios, but on android I'm getting this error : android only allows one navigation page on screen at a time

This is my MainActivity.cs
` public class MainActivity : FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

        Forms.Init(this, bundle);

        var mvxFormsApp = new MvxFormsApp();
        LoadApplication(mvxFormsApp);

        var presenter = Mvx.Resolve<IMvxViewPresenter>() as MvxFormsDroidPagePresenter;
        presenter.MvxFormsApp = mvxFormsApp;
        Mvx.Resolve<IMvxAppStart>().Start();


    }
}`

App.cs
` public override void Initialize()
{
try
{
CreatableTypes()
.EndingWith("Service")
.AsInterfaces()
.RegisterAsLazySingleton();

            RegisterAppStart<ViewModels.RootViewModel>();

            InitializeDb(false); 
            InitSettings();
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
        }
    }`

RootPage.xaml:
`<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyClass.RootPage"
Title="Welcome"

IsPresented="false">


`

RootPage.xaml.cs:
` public partial class RootPage : MasterDetailPage
{

    public RootPage()
    {
        InitializeComponent();
        NavigationPage.SetHasNavigationBar(this, false);
        InitializeMasterDetail();
    }

    private void InitializeMasterDetail()
    {            
        this.SetValue(NavigationPage.BarTextColorProperty, Color.White);
        Master = new MainMenuPage();
        Detail = new NavigationPage(new DashboardPage());
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();

    }
}`

Viewing all articles
Browse latest Browse all 81910

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>