I'm trying to figure out how to switch between two different pages in Xamarin Forms.
I do not wish to use a NavigationPage
(which has that little back arrow that is auto displayed.
I have a Login page (which is a ContentPage
) and once the person has authenticated, I then need to navigate to my Dashboard page (which is a TabbedPage
).
eg.
Next, one of the Tab's in the TabbedPage is the profile of the logged in user. As such, I need to log them out. So i'll have a button to log them out, which means I will need to navigate them back to the Login page (which was that ContentPage
).
I feel like I have two modes the user might be in.
- UnAuthorized. (
ContentPage
) - Authorized. (
TabbedPage
).
It's like .. I need to change the App
's MainPage
to be either one of those two?
Can anyone help me, please?
For a login page, the best practice is to use
Once you are on the LoginPage, you can use popModelAsync after the validation is passed:
If you like to switch between the pages then you can simply do
How to Change MainPage in xamarin forms at runtime?
this is what i have done to get result
To change MainPage to another just do:
or
BTW: You can use a NavigationPage and then HIDE the toolbar with:
You can do navigation as usual by setting MainPage in your Application instance. Small sample.
EDIT1
I submitted this answer but then I realised that I probably don't understand your problem.
EDIT2
Updated sample.