File tree 1 file changed +5
-6
lines changed
src/Controls/tests/Core.UnitTests/TestClasses
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Runtime . CompilerServices ;
5
- using System . Text ;
6
- using System . Threading . Tasks ;
7
5
8
6
namespace Microsoft . Maui . Controls . Core . UnitTests
9
7
{
10
8
public class TestWindow : Window
11
9
{
10
+ // Because the relationship from Window => Application is a weakreference
11
+ // we need to retain a reference to the Application so it doesn't get GC'd
12
+ TestApp _app ;
12
13
public TestWindow ( )
13
14
{
14
15
@@ -24,12 +25,10 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
24
25
if ( propertyName == PageProperty . PropertyName &&
25
26
Parent == null )
26
27
{
27
- var app = new TestApp ( this ) ;
28
- _ = ( app as IApplication ) . CreateWindow ( null ) ;
28
+ _app = new TestApp ( this ) ;
29
+ _ = ( _app as IApplication ) . CreateWindow ( null ) ;
29
30
}
30
31
}
31
-
32
-
33
32
}
34
33
35
34
public static class TestWindowExtensions
You can’t perform that action at this time.
0 commit comments