MainPage.xaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. using System.Windows.Navigation;
  19. using System.Diagnostics;
  20. namespace WindowsPhoneRecipes
  21. {
  22. public partial class MainPage
  23. {
  24. // Constructor
  25. public MainPage()
  26. {
  27. InitializeComponent();
  28. WindowsPhoneRecipes.Logger.Instance.AddLine();
  29. }
  30. private void btnNext_Click(object sender, RoutedEventArgs e)
  31. {
  32. // Navigate to the new page
  33. NavigationService.Navigate(new Uri("/CategoriesListingPage.xaml", UriKind.Relative));
  34. }
  35. protected override void OnNavigatedTo(NavigationEventArgs e)
  36. {
  37. base.OnNavigatedTo(e);
  38. WindowsPhoneRecipes.Logger.Instance.AddLine();
  39. }
  40. protected override void OnNavigatedFrom(NavigationEventArgs e)
  41. {
  42. base.OnNavigatedFrom(e);
  43. WindowsPhoneRecipes.Logger.Instance.AddLine();
  44. }
  45. protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
  46. {
  47. base.OnBackKeyPress(e);
  48. // due to bug, BackKey doesnt send navigation events so we handle this myself
  49. if (NavigationService.CanGoBack)
  50. {
  51. e.Cancel = true;
  52. NavigationService.GoBack();
  53. }
  54. }
  55. private void btnAppBarLog_Click(object sender, EventArgs e)
  56. {
  57. // toggles the log area visibilty
  58. if (svLog.Visibility == Visibility.Collapsed)
  59. {
  60. txbLog.Text = WindowsPhoneRecipes.Logger.Instance.Log.ToString();
  61. svLog.Visibility = Visibility.Visible;
  62. ContentPanel.Visibility = Visibility.Collapsed;
  63. }
  64. else
  65. {
  66. svLog.Visibility = Visibility.Collapsed;
  67. ContentPanel.Visibility = Visibility.Visible;
  68. }
  69. }
  70. }
  71. }