Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brunosonnino opened this issue Jul 31, 2024 · 5 comments
Open
Labels
area-AppWindow bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team

Comments

@brunosonnino
Copy link

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

@brunosonnino brunosonnino added the bug Something isn't working label Jul 31, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jul 31, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@ghost1372

This comment was marked as spam.

@brunosonnino
Copy link
Author

brunosonnino commented Aug 1, 2024

@ghost1372 The problem is not in the titlebar buttons - it's in the Titlebar itself - in your gif, you can see that the titlebar has always the same height, it doesn't change, but it should change height (or disappear when you choose collapsed). The buttons change, but the titlebar (which should change), no

@ghost1372
Copy link
Contributor

@brunosonnino oh i got it
Adding content may solve the problem, but it adds other problems

<TitleBar.Content>
    <AutoSuggestBox Width="320"/>
</TitleBar.Content>

@brunosonnino
Copy link
Author

@ghost1372 when you add the autosuggest, it goes to tall, but doesn't return to standard or hide

@JesseCol JesseCol added area-AppWindow team-CompInput Issue for IXP (Composition, Input) team and removed needs-triage Issue needs to be triaged by the area owners labels Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-AppWindow bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests

3 participants