-
Notifications
You must be signed in to change notification settings - Fork 803
Open
Labels
area-TitleBarIssues related to custom window title bars.Issues related to custom window title bars.bugSomething isn't workingSomething isn't workingclosed-DuplicateDescribed behavior is already captured by another issue.Described behavior is already captured by another issue.needs-triageIssue needs to be triaged by the area ownersIssue needs to be triaged by the area ownersteam-ControlsIssue for the Controls teamIssue for the Controls team
Description
Description:
The CenterContent inside the TitleBar does not stretch properly due to the ContentPresenter being constrained by HorizontalAlignment="Center". This causes issues when adding controls like AutoSuggestBox, which remain centered instead of filling the available space.
Steps to Reproduce:
- Add a control (e.g.,
AutoSuggestBox) to theCenterContentof theTitleBar. - Observe that the control remains centered and does not stretch, even if
HorizontalAlignment="Stretch"is set on the child element. - Resizing the window may result in unintended cropping if explicit widths are set.
Actual Behavior:
- Controls take up the full height of the title bar, which is inconsistent with the rest of the title bar layout.
- Controls remain centered and do not stretch.

- Manually setting widths leads to cropping issues on window resize.

<TitleBar.CenterContent>
<AutoSuggestBox x:Name="SearchBox" Width="480" PlaceholderText="Search..." QueryIcon="Find"/>
</TitleBar.CenterContent>Expected Behavior:
- Controls inside the
CenterContentshould stretch properly to fit the available space while maintaining correct alignment with other title bar elements. - Controls inside the center content area must follow the TitleBar specs correctly (The follwing design from titleBar-dev-spec)

Attempted Solution:
I removed HorizontalAlignment="Center" from the ContentPresenter to allow child elements to stretch properly and set VerticalAlignment="Center" to keep alignment consistent with other title bar elements.
<Grid
x:Name="PART_CenterContentPresenterGrid"
x:DeferLoadStrategy="Lazy"
Visibility="Collapsed"
Grid.Column="8">
<ContentPresenter
x:Name="PART_CenterContentPresenter"
Content="{TemplateBinding CenterContent}"
VerticalAlignment="Center"/>
</Grid>Result of Attempted Fix:
- ✅ The
CenterContentstretched correctly, and child elements likeAutoSuggestBoxbehaved as expected. - ❌ However, clicking on the center area of the title bar no longer allowed dragging the window.
Recording.2025-03-12.125951.mp4
<TitleBar.CenterContent>
<AutoSuggestBox x:Name="SearchBox" MaxWidth="480" PlaceholderText="Search..." QueryIcon="Find"/>
</TitleBar.CenterContent>NuGet package version
WinUI 3 - Windows App SDK 1.7 Preview 1: 1.7.250208002-preview1
Windows version
Windows 11 (24H2): Build 26100
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-TitleBarIssues related to custom window title bars.Issues related to custom window title bars.bugSomething isn't workingSomething isn't workingclosed-DuplicateDescribed behavior is already captured by another issue.Described behavior is already captured by another issue.needs-triageIssue needs to be triaged by the area ownersIssue needs to be triaged by the area ownersteam-ControlsIssue for the Controls teamIssue for the Controls team
Type
Projects
Status
Done