Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ public override void OnResume()
base.OnResume();

bool isCreated = _window is Window ? (bool)typeof(Window).GetProperty("IsCreated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(_window) : false;
#if NET10_0_OR_GREATER
bool isActivated = _window is Window window ? window.IsActivated : false;
#else
bool isActivated = _window is Window ? (bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(_window) : false;
#endif

if (!isCreated)
_window.Created();
Expand Down
8 changes: 8 additions & 0 deletions src/Controls/tests/DeviceTests/ControlsHandlerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ void OnBatchCommitted(object sender, Controls.Internals.EventArg<VisualElement>
#if !WINDOWS
if (window is Window controlsWindow)
{
#if NET10_0_OR_GREATER
if (!controlsWindow.IsActivated)
#else
if (!(bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(controlsWindow))
#endif
window.Activated();
}
else
Expand Down Expand Up @@ -258,7 +262,11 @@ void OnBatchCommitted(object sender, Controls.Internals.EventArg<VisualElement>


#if !WINDOWS
#if NET10_0_OR_GREATER
bool isActivated = controlsWindow?.IsActivated ?? false;
#else
bool isActivated = controlsWindow == null ? false : (bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(controlsWindow);
#endif
bool isDestroyed = controlsWindow == null ? false : (bool)typeof(Window).GetProperty("IsDestroyed", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(controlsWindow);

if (isActivated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ void OnActivated(object sender, UI.Xaml.WindowActivatedEventArgs args)
{
if (Window is not null)
{
#if NET10_0_OR_GREATER
bool isActivated = Window.IsActivated;
#else
bool isActivated = (bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(Window);
#endif
if (!isActivated)
_window.Activated();
}
Expand Down
12 changes: 12 additions & 0 deletions src/Controls/tests/DeviceTests/Stubs/WindowHandlerStub.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ void UpdateContent()
var view = _currentView.ToPlatform2(MauiContext);
if (needsToPush)
{
#if NET10_0_OR_GREATER
bool fireEvents = VirtualView is Window window ? !window.IsActivated : true;
#else
bool fireEvents = VirtualView is Window ? !(bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue((Window)VirtualView) : true;
#endif
var vc =
((IPlatformViewHandler)_currentView.Handler).ViewController;

Expand All @@ -67,7 +71,11 @@ void UpdateContent()
_workSpace.AddChildViewController(vc);
_workSpace.View.AddSubview(vc.View);
if (fireEvents && this is IElementHandler elementHandler && elementHandler.VirtualView is IWindow virtualView)
#if NET10_0_OR_GREATER
FireWindowEvent(virtualView, (window) => !window.IsActivated, () =>
#else
FireWindowEvent(virtualView, (window) => !(bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(window), () =>
#endif
{
if (!IsDisconnected)
VirtualView.Activated();
Expand Down Expand Up @@ -113,7 +121,11 @@ async void Disconnect(IView view, UIWindow platformView, Action finishedClosing)
return;
}

#if NET10_0_OR_GREATER
FireWindowEvent(virtualView, (window) => window.IsActivated, () => virtualView.Deactivated());
#else
FireWindowEvent(virtualView, (window) => (bool)typeof(Window).GetProperty("IsActivated", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(window), () => virtualView.Deactivated());
#endif

while (pvc.PresentedViewController is UIViewController mw && typeof(Microsoft.Maui.Platform.ContentView).Assembly.GetType("Microsoft.Maui.Platform.ModalWrapper").IsInstanceOfType(mw))
{
Expand Down