| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- // ----------------------------------------------------------------------------------
- // Microsoft Developer & Platform Evangelism
- //
- // Copyright (c) Microsoft Corporation. All rights reserved.
- //
- // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
- // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
- // OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
- // ----------------------------------------------------------------------------------
- // The example companies, organizations, products, domain names,
- // e-mail addresses, logos, people, places, and events depicted
- // herein are fictitious. No association with any real company,
- // organization, product, domain name, email address, logo, person,
- // places, or events is intended or should be inferred.
- // ----------------------------------------------------------------------------------
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Navigation;
- namespace WindowsPhoneRecipes
- {
- public partial class CategoryPage
- {
- public string Category { get; set; }
-
- public CategoryPage()
- {
- InitializeComponent();
-
- WindowsPhoneRecipes.Logger.Instance.AddLine();
- }
- private void btnNext_Click(object sender, RoutedEventArgs e)
- {
- // Navigate to the new page
- NavigationService.Navigate(new Uri("/ItemPage.xaml?cat=" + Category + "&item=" + (sender as Button).Name.Substring(7), UriKind.Relative));
- }
- private void btnMenu_Click(object sender, RoutedEventArgs e)
- {
- NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
- }
- private void btnCategoryList_Click(object sender, RoutedEventArgs e)
- {
- NavigationService.Navigate(new Uri("/CategoriesListingPage.xaml", UriKind.Relative));
- }
- // When page is navigated to, set data context
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- base.OnNavigatedTo(e);
- WindowsPhoneRecipes.Logger.Instance.AddLine();
- Category = this.NavigationContext.QueryString["cat"];
- if (DataContext == null)
- this.DataContext = this;
- //simulate a big load that you want to avoid during recursive back navigation
- if (NonLinearNavigationService.Instance.IsRecursiveBackNavigation == true)
- {
- WindowsPhoneRecipes.Logger.Instance.AddLine("IsRecursiveBackNavigation = true");
- return;
- }
- //else
- /*
- * DO WORK HERE - like animation, data biding, and so on...
- */
- this.ApplicationBar.IsVisible = true;
- //simulate large UI blocking work - that should be avoided all togerher
- //System.Threading.Thread.Sleep(5000);
- }
- // FOR DEBUGGING ONLY!
- //static int x = 0;
- protected override void OnNavigatedFrom(NavigationEventArgs e)
- {
- base.OnNavigatedFrom(e);
- WindowsPhoneRecipes.Logger.Instance.AddLine();
- // on navigating away from the page, hide the appbar so we dont see it if we are recursive back
- this.ApplicationBar.IsVisible = false;
- // FOR DEBUGGING only! Simualte user canceling nav event during recursive back
- //if (x == 0)
- //{
- // x++;
- //}
- //else
- //{
- // //for debuging user canceling navigation
- // // e.Cancel = true;
- //}
- }
- protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
- {
- base.OnBackKeyPress(e);
- // due to a bug, BackKey doesnt route navigation events so we handle it
- if (NavigationService.CanGoBack)
- {
- e.Cancel = true;
- NavigationService.GoBack();
- }
- }
- }
- }
|