- Navigation history management. The starting navigation history is managed by a navigation stack. Complete the following Navigation:Mainpage->Page1->Page
2-> Page 3,In fact, a navigation stack is formed:
When you press the "back-to-back key", you can also navigate based on the principle of "back-to-first-out", but consider the following:
- What is its principle? Each application has a rootframe. When you navigate to this page, the navigation framework sets each page of the application or the instance of phoneapplicationpage as the content of the framework.RootframeThere is a rootframe. backstack.
- How does it manage and store the page's historical records? Rootframe. backstack is similar to a stack operation, which stores entries in history records (Journalentry) Type.
- Can I control and operate on this stack? Of course, we can control this stack. Just as we operate on the data structure of a stack, it also has pop (operating on OS) and push operations, and push uses rootframe. removebackentry.
// The BackStack property is a collection of JournalEntry objects. foreach (JournalEntry journalEntry in RootFrame.BackStack.Reverse()) { historyListBox.Items.Insert(0, i + ": " + journalEntry.Source); i++; }
// If RemoveBackEntry is called on an empty back stack, an InvalidOperationException is thrown. // Check to make sure the BackStack has entries before calling RemoveBackEntry. if (RootFrame.BackStack.Count() > 0) RootFrame.RemoveBackEntry();
2. How to manage the magnetic stripe on the start page?
We add a checkbox to the page. When the checkbox is selected, this page is washed to the start page. Otherwise, it is taken from the start page.
/// <summary>/// Toggle pinning a Tile for this page on the Start screen./// </summary>private void PinToStartCheckBox_Click(object sender, RoutedEventArgs e){ // Try to find a Tile that has this page's URI. ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(o => o.NavigationUri.ToString().Contains(NavigationService.Source.ToString())); if (tile == null) { // No Tile was found, so add one for this page. StandardTileData tileData = new StandardTileData { Title = PageTitle.Text }; ShellTile.Create(new Uri(NavigationService.Source.ToString(), UriKind.Relative), tileData); } else { // A Tile was found, so remove it. tile.Delete(); }}