-
-
Notifications
You must be signed in to change notification settings - Fork 946
[Bug] Window Title Bar and Maximize Icon Not Updated Correctly When Restoring Maximized State via Code #1453
Description
Describe the bug
When restoring the window state to Maximized using code (e.g., via WindowState = WindowState.Maximized), the title bar does not render correctly, and the maximize button icon remains in its "restore" (normal) form instead of updating properly. This creates an inconsistent and visually broken UI state.
To Reproduce
- Implement a WindowStateSettings feature to persist window size, position, and state (including maximized) via JSON config.
- In the MainWindow.xaml.cs, restore the window state in the Loaded event:
WindowState = WindowState.Maximized;
- Run the app.
- Observe the title bar and window control buttons.
Expected behavior
When setting WindowState = WindowState.Maximized, the title bar should render properly, and the maximize/restore icon should correctly reflect the state of the window.
Screenshots
OS version
OS: Windows 11
.NET version
.NET version: .NET 9
WPF-UI NuGet version
WPF UI 4.0.2
Additional context
The issue does not occur when the user maximizes the window manually.
The problem seems tied to how the title bar and system buttons are updated when the maximized state is applied programmatically before the window is fully rendered.
