How can i navigate a content page to shell page?

Saurabh Sharma 1 Reputation point
2020-12-12T06:07:23.973+00:00

I made an app through xamarin in which i made a login page(content page) then i wanted it to navigate on a shell page through my login button but shell page is not opening and giving errors that push modal async doesn't work on this ! Kindly help regarding this how can I navigate a content page to shell page

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,355 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Gary Lewis 256 Reputation points
    2020-12-12T22:12:06.043+00:00

    I wrote an OnBoarding page and then transitioned to Shell. You can't jump into the middle of a bunch of Shell pages, but you can transition from standard navigation to Shell.

    In my App.xaml.cs file I did this:

        MainPage = new NavigationPage( new SplashView() );
    

    Then in the code-behind of my SplashView, I did this:

      public partial class SplashView : ContentPage
        {
            public SplashView()
            {
                InitializeComponent();
            }
    
            protected override async void OnAppearing()
            {
                base.OnAppearing();
    
                await Task.Delay( 2000 );
                await Application.Current.MainPage.Navigation.PopAsync();
                Application.Current.MainPage = new AppShell();
            }
        }
    
    0 comments No comments

  2. JarvanZhang 23,961 Reputation points
    2020-12-17T01:54:46.013+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Hi, @Saurabh Sharma . For this function, you could detect the login status to specify the MainPage. And set the AppShell as the MainPage instead of using the navigation method after logining in.

       public class App : Application  
       {  
           public static bool IsUserLoggedIn { get; set; }  
           public App()  
           {  
               if (!IsUserLoggedIn)  
               {  
                   MainPage = new Login(); //login in and then set the AppShell as MainPage  
               }  
               else  
               {  
                   MainPage = new AppShell();  
               }  
           }  
       }  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.