Navigated page is bank- Content is not loaded

Hi,
Im trying to load the a main page after the login page on login button click but the main page is loaded without any content (blank). If I try to load the main page instead the login page on App start the page loads with the content without any issues.

My requirement is to load the mainpage after login page without the navigation panel.

Please assist.

App.cs
public App()
{
InitializeComponent();
MainPage = new LoginPage();
//MainPage = new NavigationPage(new LoginPage()); //Tried this method but no luck
}

Loginpage.cs

            if (logintrue == true)
            {
                App.Current.MainPage = new MainPage();
                //await Navigation.PushAsync(new MainPage());               //Tried this method but no luck
                //await Navigation.PushModalAsync(new MainPage());          //Tried this method but no luck
            }

Answers

  • chetanrawatchetanrawat ✭✭✭ USMember ✭✭✭

    Can you please share main page code?

  • RasikauRasikau ✭✭ Member ✭✭

    Dear chetanrawat,
    Below is the code behind and the AXML.

    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            Debug.Write("Page Loaded");
        }
    }
    

    <?xml version="1.0" encoding="utf-8" ?>

    <ContentPage.Content>
        <StackLayout>
            <Label Text="Main Page"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
    

  • PaulNTUPaulNTU ✭✭✭ USMember ✭✭✭

    @Rasikau Where is your "if(logintrue == true)" code located? Is it in a separate thread (in an async method) or in the constructor for the loginpage.cs?

Sign In or Register to comment.