Skip to content

TitleBar doesn't respect AppWindow.TitleBar.PreferredHeightOption #9863

Open
@brunosonnino

Description

@brunosonnino

Describe the bug

The TitleBar has always the Standard Height and doesn't respect the AppWindow.TitleBar.PreferredHeightOption setting

Steps to reproduce the bug

  • Create a Blank WinUI3 app
  • Upgrade the WindowsAppSdk Nuget package to 1.6 experimental 2
  • Change the project file to add
<WindowsSdkPackageVersion>10.0.19041.35-preview</WindowsSdkPackageVersion>

Add this code in MainWindow.xaml.cs

public sealed partial class MainWindow : Window
{
    public string[] TitleBarHeights = ["Standard", "Tall", "Collapsed"];
    public MainWindow()
    {
        this.InitializeComponent();
        ExtendsContentIntoTitleBar = true;
    }

    private void TitleBarHeight_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (sender is RadioButtons radioButtons)
        {
            AppWindow.TitleBar.PreferredHeightOption = radioButtons.SelectedIndex switch
            {
                1 => TitleBarHeightOption.Tall,
                2 => TitleBarHeightOption.Collapsed,
                _ => TitleBarHeightOption.Standard
            };
        }
    }
}

Add this code to MainWindow.xaml

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <TitleBar Title="Title" Subtitle="SubTitle" IsBackButtonVisible="True" IsPaneToggleButtonVisible="True">
        <TitleBar.IconSource>
            <FontIconSource Glyph="&#xe713;" />
        </TitleBar.IconSource>
    </TitleBar>
    <Grid Grid.Row="1" Background="Aqua">
        <RadioButtons ItemsSource="{x:Bind TitleBarHeights}" HorizontalAlignment="Center" VerticalAlignment="Center"
                SelectedIndex="0" SelectionChanged="TitleBarHeight_SelectionChanged" />
    </Grid>
</Grid>

Run the project. If you change the radio button, the bar stays the same, but the title bar height changes (you can check by trying the buttons and the in-app-toolbar in the app). For the Collapsed settings, the buttons disappear, and you can't move the window anymore

This project has a sample of the bug: https://github.com/brunosonnino/TitleBarBugs/tree/main/2%20-%20TitleBarHeight

Expected behavior

The TitleBar should respect the setting

Screenshots

image
Standard
image
Tall
image
Collapsed

NuGet package version

WinUI 3 - Windows App SDK 1.6 Experimental 2: 1.6.240701003-experimental2

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-AppWindowbugSomething isn't workingteam-CompInputIssue for IXP (Composition, Input) team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions