Skip to content

Commit

Permalink
fix!: Remove Application.OnWindowCreated from WinUI tree
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Application.OnWindowCreated does not exist in WinAppSDK
  • Loading branch information
MartinZikmund committed May 8, 2023
1 parent ade59d3 commit bb368b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ private SuspendingOperation CreateSuspendingOperation() =>
new SuspendingOperation(DateTimeOffset.Now.AddSeconds(0), null);
#endif

#if !HAS_UNO_WINUI
protected virtual void OnWindowCreated(global::Windows.UI.Xaml.WindowCreatedEventArgs args)
{
}
Expand All @@ -398,6 +399,7 @@ internal void RaiseWindowCreated(Window window)
{
OnWindowCreated(new WindowCreatedEventArgs(window));
}
#endif

private void SetRequestedTheme(ApplicationTheme requestedTheme)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ internal Window(bool internalUse)
private void InitializeCommon()
{
InitDragAndDrop();

#if !HAS_UNO_WINUI
if (Application.Current != null)
{
Application.Current.RaiseWindowCreated(this);
Expand All @@ -100,6 +102,7 @@ private void InitializeCommon()
this.Log().Warn("Unable to raise WindowCreatedEvent, there is no active Application");
}
}
#endif

Background = SolidColorBrushHelper.White;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/WindowCreatedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#if !HAS_UNO_WINUI
using System;
using Windows.Foundation;
using Windows.Foundation.Metadata;

namespace Windows.UI.Xaml
{
public sealed partial class WindowCreatedEventArgs
Expand All @@ -14,3 +16,4 @@ public Window Window
}
}
}
#endif

0 comments on commit bb368b8

Please sign in to comment.