@@ -23,11 +23,18 @@ namespace $ext_safeprojectname$
23
23
/// </summary>
24
24
public sealed partial class App : Application
25
25
{
26
- /// <summary>
27
- /// Initializes the singleton application object. This is the first line of authored code
28
- /// executed, and as such is the logical equivalent of main() or WinMain().
29
- /// </summary>
30
- public App ( )
26
+ #if NET5_0 && WINDOWS
27
+ private Window _window ;
28
+
29
+ #else
30
+ private Windows . UI . Xaml . Window _window ;
31
+ #endif
32
+
33
+ /// <summary>
34
+ /// Initializes the singleton application object. This is the first line of authored code
35
+ /// executed, and as such is the logical equivalent of main() or WinMain().
36
+ /// </summary>
37
+ public App ( )
31
38
{
32
39
InitializeLogging ( ) ;
33
40
@@ -53,13 +60,13 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
53
60
#endif
54
61
55
62
#if NET5_0 && WINDOWS
56
- var window = new Window ( ) ;
57
- window . Activate ( ) ;
63
+ _window = new Window ( ) ;
64
+ _window . Activate ( ) ;
58
65
#else
59
- var window = Windows . UI . Xaml . Window . Current ;
66
+ _window = Windows . UI . Xaml . Window . Current ;
60
67
#endif
61
68
62
- var rootFrame = window . Content as Frame ;
69
+ var rootFrame = _window . Content as Frame ;
63
70
64
71
// Do not repeat app initialization when the Window already has content,
65
72
// just ensure that the window is active
@@ -76,7 +83,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
76
83
}
77
84
78
85
// Place the frame in the current Window
79
- window . Content = rootFrame ;
86
+ _window . Content = rootFrame ;
80
87
}
81
88
82
89
#if ! ( NET5_0 && WINDOWS )
@@ -91,7 +98,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
91
98
rootFrame . Navigate ( typeof ( MainPage ) , e . Arguments ) ;
92
99
}
93
100
// Ensure the current window is active
94
- window . Activate ( ) ;
101
+ _window . Activate ( ) ;
95
102
}
96
103
}
97
104
0 commit comments