0

Getting Exception when set the App.Main Page in ViewModel.

Application.Current.MainPage = new NavigationPage(new HomeView());

HomeView is a MasterDetailPage.

in a Detail Page i have a Content page that have Custom horizontal scrollView, and Content View that have itemSource Bindable Property.

System.NullReferenceException at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0×00007] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:292 at mySMARTSMobile.Droid.Renderers.Droid_NavigationRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0×00002] in /Users/Ankit/Desktop/Himanshu/SMARTS/mySMARTSMobile.Droid/Renderers/Droid_NavigationRenderer.cs:45

Xamarin.Forms Version: 2.3.4.247

Please guild me why i am getting this Exception, I am beginner for Xamarin Forms.

public partial class HomeView : MasterDetailPage
{
    public HomeView()
    {
        InitializeComponent();
        NavigationPage.SetHasNavigationBar(this, false);

        var vm = new MainViewModel();
        vm.GetData();
        Detail = new NavigationPage(new MainView(vm));
        //System.GC.Collect();
    }

    protected async override void OnAppearing()
    {
        base.OnAppearing();
        //await Task.Delay(10);
    }
}

In LoginViewModel

Application.Current.MainPage = new NavigationPage(new HomeView());

0 Answers0