Prism Navigation Clear History

pmhart83pmhart83 USMember ✭✭✭
edited June 2016 in Xamarin.Forms

We have been using Prism in our Xamarin.Forms project. There is a sign-in dialog which switches between create new user and sign-in. Currently every time the user switches between create and sign-in a new ContentPage is created in memory when using the .Navigate to show other page. When we want to call the INavigtaionService .GoBack(), there could be many pages.

What I want is to call .Navigate and go back to the main page, with no sign-in / create pages in the middle.

I noticed that the INavigation of a page supports removing history. Is this just something in Prism that is not implemented. Is there another way to do dialogs and be "Prism Friendly".

Posts

  • pmhart83pmhart83 USMember ✭✭✭

    I ended up using a NavigationPage and just injecting a navigation manager with autofac. Simple and provides native animations.

  • N_BauaN_Baua INMember ✭✭✭✭✭

    @pmhart83 said:
    I ended up using a NavigationPage and just injecting a navigation manager with autofac. Simple and provides native animations.

    Hi,

    Could have used for example,

    > await _navigationService.NavigateAsync("app:///Navigation/Login?appModuleRefresh=OnInitialized");
    

    where Navigation is alias for NavigationPage and Login is your view name,

    I am just suggesting this here as I was finding the solution myself and this is the first result came up in Google search.
    I didn't got much luck with the forums and searches so I just tried with whatever on hand,

    My use-case:
    Need to logout the user and be able to restrict the user from navigating back to previous view(s) by redirecting him/her on Login screen (or as the case may be.)

    Notice the appModuleRefresh=OnInitialized parameter, which did the trick for me.

    Hope this helps, to everyone who want to clear the navigation stack.

    Regards,
    N Baua

Sign In or Register to comment.