-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set Window Parent before initialize the child ContentPage (#8653)
* Set Window Parent before initialize the child ContentPage * - fire appearing after parent is set on window * Update Application.Impl.cs * - fix up tests * - fix application stub * - wire up test app to test window * - fix additional windows Co-authored-by: Shane Neuville <[email protected]>
- Loading branch information
1 parent
448dfb9
commit ca948d7
Showing
17 changed files
with
199 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Maui.Controls.Core.UnitTests | ||
{ | ||
public class TestApp : Application | ||
{ | ||
ContentPage _withPage; | ||
TestWindow _window; | ||
|
||
public TestApp() : base(false) | ||
{ | ||
|
||
} | ||
|
||
public TestApp(TestWindow window) : base(false) | ||
{ | ||
_window = window; | ||
} | ||
|
||
public TestWindow CreateWindow() => | ||
(TestWindow)(this as IApplication).CreateWindow(null); | ||
|
||
protected override Window CreateWindow(IActivationState activationState) | ||
{ | ||
return _window ?? new TestWindow(_withPage ?? new ContentPage()); | ||
} | ||
|
||
public TestWindow CreateWindow(ContentPage withPage) | ||
{ | ||
_withPage = withPage; | ||
return (TestWindow)(this as IApplication).CreateWindow(null); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/Core.UnitTests/TestClasses/TestWindow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Maui.Controls.Core.UnitTests | ||
{ | ||
public class TestWindow : Window | ||
{ | ||
public TestWindow() | ||
{ | ||
|
||
} | ||
|
||
public TestWindow(Page page) : base(page) | ||
{ | ||
} | ||
|
||
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) | ||
{ | ||
base.OnPropertyChanged(propertyName); | ||
if (propertyName == PageProperty.PropertyName && | ||
Parent == null) | ||
{ | ||
var app = new TestApp(this); | ||
_ = (app as IApplication).CreateWindow(null); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.