25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

App.xaml.cs 1.4 KiB

7 년 전
7 년 전
7 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using Windows.ApplicationModel;
  3. using Windows.ApplicationModel.Activation;
  4. using Windows.UI.Xaml;
  5. using Windows.UI.Xaml.Controls;
  6. using Windows.UI.Xaml.Navigation;
  7. namespace MQTTnet.TestApp.UniversalWindows
  8. {
  9. sealed partial class App
  10. {
  11. public App()
  12. {
  13. InitializeComponent();
  14. Suspending += OnSuspending;
  15. }
  16. protected override void OnLaunched(LaunchActivatedEventArgs e)
  17. {
  18. if (!(Window.Current.Content is Frame rootFrame))
  19. {
  20. rootFrame = new Frame();
  21. rootFrame.NavigationFailed += OnNavigationFailed;
  22. Window.Current.Content = rootFrame;
  23. }
  24. if (e.PrelaunchActivated == false)
  25. {
  26. if (rootFrame.Content == null)
  27. {
  28. rootFrame.Navigate(typeof(MainPage), e.Arguments);
  29. }
  30. Window.Current.Activate();
  31. }
  32. }
  33. void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
  34. {
  35. throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
  36. }
  37. private void OnSuspending(object sender, SuspendingEventArgs e)
  38. {
  39. var deferral = e.SuspendingOperation.GetDeferral();
  40. deferral.Complete();
  41. }
  42. }
  43. }