ItemPage.xaml.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // ----------------------------------------------------------------------------------
  2. // Microsoft Developer & Platform Evangelism
  3. //
  4. // Copyright (c) Microsoft Corporation. All rights reserved.
  5. //
  6. // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  7. // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  8. // OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  9. // ----------------------------------------------------------------------------------
  10. // The example companies, organizations, products, domain names,
  11. // e-mail addresses, logos, people, places, and events depicted
  12. // herein are fictitious. No association with any real company,
  13. // organization, product, domain name, email address, logo, person,
  14. // places, or events is intended or should be inferred.
  15. // ----------------------------------------------------------------------------------
  16. using System;
  17. using System.Windows;
  18. namespace WindowsPhoneRecipes
  19. {
  20. public partial class ItemPage
  21. {
  22. public string Category { get; set; }
  23. public string ItemId { get; set; }
  24. public ItemPage()
  25. {
  26. InitializeComponent();
  27. WindowsPhoneRecipes.Logger.Instance.AddLine();
  28. }
  29. protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
  30. {
  31. base.OnNavigatedTo(e);
  32. WindowsPhoneRecipes.Logger.Instance.AddLine();
  33. Category = this.NavigationContext.QueryString["cat"];
  34. ItemId = this.NavigationContext.QueryString["item"];
  35. if (DataContext == null)
  36. this.DataContext = this;
  37. if (NonLinearNavigationService.Instance.IsRecursiveBackNavigation == true)
  38. {
  39. WindowsPhoneRecipes.Logger.Instance.AddLine("IsRecursiveBackNavigation = true");
  40. return;
  41. }
  42. //else
  43. /*
  44. * DO WORK HERE - like animation, data biding, and so on...
  45. */
  46. this.ApplicationBar.IsVisible = true;
  47. }
  48. protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
  49. {
  50. base.OnNavigatingFrom(e);
  51. WindowsPhoneRecipes.Logger.Instance.AddLine();
  52. this.ApplicationBar.IsVisible = false;
  53. }
  54. protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
  55. {
  56. base.OnBackKeyPress(e);
  57. // due to bug, BackKey doesnt send navigation events so we handle this myself
  58. if (NavigationService.CanGoBack)
  59. {
  60. e.Cancel = true;
  61. NavigationService.GoBack();
  62. }
  63. }
  64. private void btnCategory_Click(object sender, RoutedEventArgs e)
  65. {
  66. NavigationService.Navigate(new Uri("/CategoryPage.xaml?cat=" + Category, UriKind.Relative));
  67. }
  68. private void btnCategoryList_Click(object sender, RoutedEventArgs e)
  69. {
  70. NavigationService.Navigate(new Uri("/CategoriesListingPage.xaml", UriKind.Relative));
  71. }
  72. private void btnMenu_Click(object sender, RoutedEventArgs e)
  73. {
  74. NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
  75. }
  76. private void btnItem_Click(object sender, RoutedEventArgs e)
  77. {
  78. NavigationService.Navigate(new Uri("/ItemPage.xaml?cat=" + Category + "&item=" + (ItemId == "1" ? "2" : "1"), UriKind.Relative));
  79. }
  80. }
  81. }