0

In my new Xamarin.Forms App I start with Login Page witch is rendered as NavigationPage. After the login I show the user a Flyout Page. If an item from the Flyout is selected this page will be displayed in the Detail section of the Flyout Page as Navigation Page. The selected page has a button and when the user tapps the button I want to navigate to a new Navigation Page witch is not rendered in the Flyout Page.
I have tried to convert the FlyoutPage to a NavigationPage, but this wasn't a good idea.
Do you have any idea to solve this problem? When I navigate to the new NavigationPage the user should not be able to see or to open the Flyout.

Here you can see my XAML:

<FlyoutPage>

    <FlyoutPage.Flyout>
        <pages:RootPageFlyout x:Name="FlyoutPage" />
    </FlyoutPage.Flyout>

    <FlyoutPage.Detail>
        <NavigationPage>
            <x:Arguments>
                <pages:MainPage />
            </x:Arguments>
        </NavigationPage>
    </FlyoutPage.Detail>

</FlyoutPage>

And this is the code behind of the XAML

public partial class RootPage : FlyoutPage
{
    public RootPage()
    {
        InitializeComponent();
        FlyoutPage.ListView.ItemSelected += ListView_ItemSelected;
    }

    private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        var item = e.SelectedItem as RootPageFlyoutMenuItem;
        if (item == null) return;

        var page = (Page)Activator.CreateInstance(item.TargetType);
        page.Title = item.Title;

        Detail = new NavigationPage(page);
        IsPresented = false;

        FlyoutPage.ListView.SelectedItem = null;
    }
}
  • Why not switching to Shell? Related https://stackoverflow.com/q/65186262/ – Cfun Apr 05 '21 at 17:57
  • Instead of trying to set the page that way, what you may want to try to do is Navigation.PushModalAsync(page). By setting the detail the user will still know about the flyout since they are still within the fly out – SomeStudent Apr 05 '21 at 21:00
  • (1. Using shell mentioned from Cfun. 2. Using modal page from SomeStudent) 3. Create a new navigation stack, which jumps out the Flyout container. 4. Fake a flyout. – Shaw Apr 05 '21 at 22:25
  • I have switched the App to Shell. I didn't use Shell before because in my custom Navigation Service I had an additional parameter for an object. – HerrNetzheimer Apr 06 '21 at 17:11

0 Answers0