MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / App

Class App

SampleApps/webview2_sample_uwp/App.xaml.cs:20–124  ·  view source on GitHub ↗

Provides application-specific behavior to supplement the default Application class.

Source from the content-addressed store, hash-verified

18 /// Provides application-specific behavior to supplement the default Application class.
19 /// </summary>
20 sealed partial class App : Application
21 {
22 private readonly Settings _settings;
23
24 public Settings Settings
25 {
26 get { return _settings; }
27 }
28
29 // Syntactic sugar to avoid having to cast
30 // to App in other parts of the application.
31 public static App Instance
32 {
33 get { return (App)Current; }
34 }
35
36 /// <summary>
37 /// Initializes the singleton application object. This is the first line of authored code
38 /// executed, and as such is the logical equivalent of main() or WinMain().
39 /// </summary>
40 public App()
41 {
42 _settings = new Settings();
43
44 InitializeComponent();
45 Suspending += OnSuspending;
46 }
47
48 /// <summary>
49 /// Invoked when the application is launched normally by the end user. Other entry points
50 /// will be used such as when the application is launched to open a specific file.
51 /// </summary>
52 /// <param name="e">Details about the launch request and process.</param>
53 protected override void OnLaunched(LaunchActivatedEventArgs e)
54 {
55 Frame rootFrame = Window.Current.Content as Frame;
56
57 // Do not repeat app initialization when the Window already has content,
58 // just ensure that the window is active
59 if (rootFrame == null)
60 {
61 // Create a Frame to act as the navigation context and navigate to the first page
62 rootFrame = new Frame();
63
64 rootFrame.NavigationFailed += OnNavigationFailed;
65
66 if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
67 {
68 //TODO: Load state from previously suspended application
69 }
70
71 // Place the frame in the current Window
72 Window.Current.Content = rootFrame;
73 }
74
75 if (e.PrelaunchActivated == false)
76 {
77 if (rootFrame.Content == null)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected