Skip to content

[Bug] Window Title Bar and Maximize Icon Not Updated Correctly When Restoring Maximized State via Code #1453

@VahedCivil

Description

@VahedCivil

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.

LibTreeView.zip

To Reproduce

  1. Implement a WindowStateSettings feature to persist window size, position, and state (including maximized) via JSON config.
  2. In the MainWindow.xaml.cs, restore the window state in the Loaded event:

WindowState = WindowState.Maximized;

  1. Run the app.
  2. 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

Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions