question

PatrickRyder avatar image
0 Votes"
PatrickRyder asked PatrickRyder commented

Is it possible to do wizard-style navigation with Xamarin Shell?

My application architecture is a natural fit for a wizard-style. In other words, I want to explicitly lead users from one screen to the next. Usually they can go back but sometimes even this doesn't make sense and they need to be held on the current screen until something happens (i.e. the screen is modal, with no back button).

I can build the structure of this using Xamarin Shell but I need to get rid of the flyout menu and the tab bar. And sometimes I need to make sure there is no back button.

I was using the old Xamarin navigation hierarchy, with PushAsync(), PopAsync(), PopToRootAsync(), etc. This was mostly working but the problem of having separate navigation stacks for modal and non-modal pages seems to make it unworkable.

The specific problem is that when popping a modal page, no event occurs back in the parent page. Also, there appears to be no way to pop back to the root from a modal page.

Is wizard-style navigation possible in Xamarin Shell?

Any advice or pointers to information would be welcome.

Kind wishes - Patrick



dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered PatrickRyder commented

Hello,​

Welcome to our Microsoft Q&A platform!

I can build the structure of this using Xamarin Shell but I need to get rid of the flyout menu and the tab bar. And sometimes I need to make sure there is no back button.

Do you want to achieve this for a page that is going to navigate to? Just use the navigation method and the new page will not contains the flyout menu or tabbar. Modal page doesn't show the back button.

private async void Button_Clicked(object sender, EventArgs e)
{
    Navigation.PushModalAsync(new TestPage());
}

The specific problem is that when popping a modal page, no event occurs back in the parent page. Also, there appears to be no way to pop back to the root from a modal page.

Try to detect the OnAppearing method of the parent page, the method will be called when the page is shown on the screen. To back to the root page, you could reset the MainPage.

App.Current.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.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JarvanZhang-MSFT

Thank you for that. I think it will do what I need.

Constructing a new instance of Shell just to go back to root does feel like a bit of hack for such a common use-case, though.

Kind wishes - Patrick

0 Votes 0 ·