简体   繁体   中英

Navigation to a previous tabbed page in Xamarin Forms

I asked a similar question yesterday but I've tried out some new techniques, and am looking for further advice:

I currently have a tabbed iOS xamarin.forms application like so:

 <TabbedPage>
     <local:UploadPage Title="Upload" IconImageSource="upload.png"/>
     <NavigationPage Title="Camera" IconImageSource="camera2.png">
         <x:Arguments>
             <local:CameraPage />
         </x:Arguments>
     </NavigationPage>
</TabbedPage> 

I'd like to be able to click the camera tab, take a picture, and then the app will automatically go back to the "upload" tab upon exiting the camera.

However, I can't seem to figure out how to accomplish this.

I've tried using: await Navigation.PushAsync(new UploadPage()); but this just pushed a new page onto the "camera" tab - what im really wanting is to somehow return control back to the first tab called "upload".

I uploaded a gif of what it is I'm wanting - just pretend that at the end of the gif instead of manually clicking the first tab, ideally the app would automatically take you there

在此处输入图像描述

Any idea on how to accomplish this? any advice would be appreciated.

EDIT:

I've also tried setting the current page like so:

Application.Current.MainPage = new UploadPage();

However this causes my tab bar at the bottom of the screen to disappear, and i can only see the one page i pushed to the stack, without access to my 2 tabs.

set the TabbedPage 's CurrentPage property

var tab = (TabbedPage)Application.Current.MainPage;
tab.CurrentPage = tab.Children[0];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM