Windows Phone 7 background history management and start page block management

Source: Internet
Author: User
  1. 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();   }}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.