In my Universal app, I want to use a Frame
to navigate through my app. I also have a breadcrumb, as per the designs. Now I don't really know how to handle things when the user wants to go back multiple pages.
My breadcrumb items are simple strings that I display using a XAML
ListView
. I find the index of the breadcrumb the user clicked on and I try to go back so many times.
I tried using a for loop:
private void Breadcrumb_Item_Tapped(object sender, TappedRoutedEventArgs e)
{
var breadcrumb = ((sender as Grid).DataContext as string);
for(int i = 1; i < Breadcrumbs.Count - Breadcrumbs.indexOf(breadcrumb); i++)
{
frame.GoBack();
}
}
But the frame.GoBack()
doesn't always work, I'm guessing because it is going too fast after the GoBack()
call before. I don't want to use a sleep method, because it should be instant.
What can I do to go back multiple pages?
I would suggest using frame.BackStack.RemoveAt(frame.BackStackDepth-1)
This way you will remove the entries from the stack without actually navigating. Use a loop to decide when you should stop removing and then execute a final frame.GoBack()
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.