Move IsAlwaysOnTop logic from XAML to code-behind

IsAlwaysOnTop is now set programmatically in MainWindow.xaml.cs instead of XAML. Added logging for when IsAlwaysOnTop is set. Removed BringToFront() calls and related logs, as setting IsAlwaysOnTop in code ensures the window stays on top.
This commit is contained in:
Yu Leng
2025-12-19 10:54:06 +08:00
parent 3fa044d44c
commit 40a1245b86
2 changed files with 4 additions and 4 deletions

View File

@@ -13,7 +13,6 @@
xmlns:winuiex="using:WinUIEx"
MinWidth="0"
MinHeight="0"
IsAlwaysOnTop="True"
IsMaximizable="False"
IsMinimizable="False"
IsResizable="False"

View File

@@ -148,15 +148,16 @@ namespace PowerDisplay
// CRITICAL: WinUI3 windows must be Activated at least once to display properly.
// In PowerToys mode, window is created but never activated until first show.
// Without Activate(), Show() may not actually render the window on screen.
// Note: IsAlwaysOnTop="True" in XAML ensures window appears above others.
Logger.LogTrace("ShowWindow: Calling this.Activate()");
this.Activate();
// Now show the window - it should appear at the correct size (WinUIEx simplified)
Logger.LogTrace("ShowWindow: Calling this.Show()");
this.Show();
Logger.LogTrace("ShowWindow: Calling this.BringToFront()");
this.BringToFront();
// Ensure window stays on top of other windows
this.IsAlwaysOnTop = true;
Logger.LogTrace("ShowWindow: IsAlwaysOnTop set to true");
// Clear focus from any interactive element (e.g., Slider) to prevent
// showing the value tooltip when the window opens