diff --git a/src/Files.App/Files.App.csproj b/src/Files.App/Files.App.csproj index 8c46ff2a08f5..3c5d26a9fdf4 100644 --- a/src/Files.App/Files.App.csproj +++ b/src/Files.App/Files.App.csproj @@ -85,6 +85,7 @@ + diff --git a/src/Files.App/MainWindow.xaml b/src/Files.App/MainWindow.xaml index 590953c08e89..1b4edc49fc36 100644 --- a/src/Files.App/MainWindow.xaml +++ b/src/Files.App/MainWindow.xaml @@ -1,9 +1,10 @@  - diff --git a/src/Files.App/MainWindow.xaml.cs b/src/Files.App/MainWindow.xaml.cs index 34f4aed86bb6..4595f262262e 100644 --- a/src/Files.App/MainWindow.xaml.cs +++ b/src/Files.App/MainWindow.xaml.cs @@ -13,15 +13,20 @@ namespace Files.App { - public sealed partial class MainWindow : WindowEx + public sealed partial class MainWindow : WinUIEx.WindowEx { private static MainWindow? _Instance; public static MainWindow Instance => _Instance ??= new(); - public MainWindow() : base(minWidth: 516, minHeight: 416) + public nint WindowHandle { get; } + + public MainWindow() { InitializeComponent(); + WindowHandle = WinUIEx.WindowExtensions.GetWindowHandle(this); + MinHeight = 416; + MinWidth = 516; ExtendsContentIntoTitleBar = true; Title = "Files"; AppWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; @@ -188,9 +193,8 @@ public async Task InitializeApplicationAsync(object activatedEventArgs) Win32Helper.BringToForegroundEx(new(WindowHandle)); } - if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)) && - AppWindow.Presenter is OverlappedPresenter presenter) - presenter.Restore(); // Restore window if minimized + if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle))) + WinUIEx.WindowExtensions.Restore(Instance); // Restore window if minimized } private Frame? EnsureWindowIsInitialized()