Xamarin.forms shell navigate to basic page, no flyout, no tabpage

Emil Alipiev 271 Reputation points
2021-05-07T05:52:44.02+00:00

I want to have simple page routing on my appshell, no flyout, no tabbedpage etc. Is it not posible?

when i define

<ShellItem
Title="LoginPage"
FlyoutItemIsVisible="False"
Route="login">
<ShellContent ContentTemplate="{DataTemplate local:LoginPage}" />
</ShellItem>

like above, it displays a 1 item flyout menu. why? i am not defining a FlyoutItem. Is there a way to achieve this using

MainPage = new AppShell();

or should i use classic way

MainPage = new LoginPage();

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

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-05-07T07:41:56.093+00:00

    Hello,

    Welcome to Microsoft Q&A!

    In shell project even a simply ShellContent will be wrapped inside flyout menu .

    The best way is to set LoginPage as MainPage in App af frist .

    And then change the MainPage to AppShell after login successfully .

    Update

    Just a simple sample

    Route

       static class Route  
           {  
               private static Dictionary<string,Type> dic = new Dictionary<string, Type>();  
         
               public static void RegisterRoute(string path , Type type)  
               {  
                   if (path == null || path.Length == 0) return;  
         
                   dic[path] = type;  
               }  
         
               public static void GoToAsync(string page)  
               {  
                   if (dic[page] == null)  
                   {  
                       //invalid page  
                       return;  
                   }  
         
                   var _p = Activator.CreateInstance(dic[page]) as Page;  
         
                   if (App.Current.MainPage == null)  
                   {                 
                       App.Current.MainPage = new NavigationPage(_p);  
                       return;  
                   }  
         
                   App.Current.MainPage.Navigation.PushAsync( _p,true);  
               }  
           }  
    

    App

       public App()  
               {  
                   InitializeComponent();  
         
                   Route.RegisterRoute("login", typeof(LoginPage));  
                   Route.RegisterRoute("login/main", typeof(MainPage));  
         
                   Route.GoToAsync("login");  
         
               }  
    

    LoginPage

       private void Button_Clicked(object sender, EventArgs e)  
               {  
                   Route.GoToAsync("login/main");  
               }  
    

    Best Regards,
    Cole Xia


    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful