Forum Xamarin.Forms

Remove previous page from navigation stack memory using Xamarin forms in UWP application

RaviDixitRaviDixit USMember ✭✭

I have read this post earlier but the solution provided over there is pretty much which I have already tried and its not working

In my navigation stack I have views A, B, C, D and from view D I want to navigate / pop to B

I am trying to remove a view from the navigation stack memory using the below code

           var stackArray = navigation.NavigationStack;

           // here the count is 6
           int viewCounts = Convert.ToInt32(stackArray.Count); 

           int viewIndexToRemove = viewCounts - 1;

         // here the same view is selected that I want to remove from the stack
         Page pageToRemove = navigation.NavigationStack[viewIndexToRemove];  

           // assuming the view is removed the count should be 5

           // the count becomes zero here don't know why
           var navStackAfterPageRemove = navigation.NavigationStack; 

      // here i get a crash as the entire stack is zero

The problem here is that when i try to remove one page from the stack the entire navigation stack flushes out and the count becomes zero, and I don't want to mess up the navigation stack by applying some patch work here so would like your suggestions on how this can be achieved.

I am trying to achieve this functionality in windows tablet based application using Xamarin forms

Sign In or Register to comment.