diff --git a/CoreAppUWP/CoreAppUWP.csproj b/CoreAppUWP/CoreAppUWP.csproj
index e76181f..96f505d 100644
--- a/CoreAppUWP/CoreAppUWP.csproj
+++ b/CoreAppUWP/CoreAppUWP.csproj
@@ -12,7 +12,7 @@
win10-$(Platform).pubxml
https://github.com/wherewhere/CoreAppUWP
win-x86;win-x64;win-arm64
- net8.0-windows10.0.22621.0
+ net7.0-windows10.0.22621.0
10.0.17763.0
partial
True
diff --git a/CoreAppUWP/Helpers/UIHelper.cs b/CoreAppUWP/Helpers/UIHelper.cs
index 50f068d..24c8f09 100644
--- a/CoreAppUWP/Helpers/UIHelper.cs
+++ b/CoreAppUWP/Helpers/UIHelper.cs
@@ -3,6 +3,7 @@
using System.Threading;
using System.Threading.Tasks;
using Windows.Foundation.Metadata;
+using Windows.Graphics.Display;
namespace CoreAppUWP.Helpers
{
@@ -10,6 +11,12 @@ public static class UIHelper
{
public static bool HasStatusBar => ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar");
+ public static int GetActualPixel(this double pixel)
+ {
+ double currentDpi = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
+ return Convert.ToInt32(pixel * currentDpi);
+ }
+
public static string ExceptionToMessage(this Exception ex)
{
StringBuilder builder = new();
diff --git a/CoreAppUWP/Helpers/WindowHelper.cs b/CoreAppUWP/Helpers/WindowHelper.cs
index f1abe60..6985082 100644
--- a/CoreAppUWP/Helpers/WindowHelper.cs
+++ b/CoreAppUWP/Helpers/WindowHelper.cs
@@ -1,4 +1,6 @@
using CoreAppUWP.Common;
+using Microsoft.UI;
+using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System;
using System.Collections.Generic;
@@ -6,6 +8,9 @@
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.ViewManagement;
+using Windows.Win32.Foundation;
+using Windows.Win32.System.WinRT;
+using WinRT;
namespace CoreAppUWP.Helpers
{
@@ -48,6 +53,24 @@ public static void TrackWindow(this Window window)
}
}
+ public static AppWindow GetAppWindow(this CoreWindow window)
+ {
+ if (!ActiveAppWindows.TryGetValue(window, out AppWindow appWindow))
+ {
+ HWND handle = window.As().WindowHandle;
+ WindowId id = Win32Interop.GetWindowIdFromWindow(handle);
+ appWindow = AppWindow.GetFromWindowId(id);
+ window.Closed += (sender, args) =>
+ {
+ ActiveAppWindows.Remove(window);
+ window = null;
+ };
+ ActiveAppWindows[window] = appWindow;
+ }
+ return appWindow;
+ }
+
public static Dictionary ActiveWindows { get; } = [];
+ public static Dictionary ActiveAppWindows { get; } = [];
}
}
diff --git a/CoreAppUWP/Pages/MainPage.xaml b/CoreAppUWP/Pages/MainPage.xaml
index d61c81e..9d109f6 100644
--- a/CoreAppUWP/Pages/MainPage.xaml
+++ b/CoreAppUWP/Pages/MainPage.xaml
@@ -16,7 +16,8 @@
Height="48"
VerticalAlignment="Top"
Canvas.ZIndex="1"
- IsHitTestVisible="True">
+ IsHitTestVisible="True"
+ SizeChanged="CustomTitleBar_SizeChanged">
@@ -56,10 +57,12 @@
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
-