Skip to content

TitleBar title doesn't propagate to window #10557

@dotMorten

Description

@dotMorten

Describe the bug

When setting the Title and subtitle on the titlebar control, the actual window's title stays "WinUI Desktop".
This means when you hover on the taskbar, it'll still show the default "WinUI Desktop", and if you enable narrator the wrong window title will be spoken when the window activates

Steps to reproduce the bug

  1. Create a window with the new TitleBar
  2. Set the Title and subtitle of the TitleBar
  3. Run the app and hover on the task bar. Notice the window title:
    Image
  4. Start Narrator and activate the window. Notice that the narrator will say "WinUI Desktop", and not the TitleBar's Title.

Expected behavior

The correct taskbar title should be set.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.7.1: 1.7.250401001

Windows version

Windows 11 (24H2): Build 26100

Additional context

As a workaround you can do something ugly like this, but this really shouldn't be necessary and the issue is easily overlooked and leads to accessibility issues if you forget to add something like this:

        public MainWindow()
        {
            this.InitializeComponent();
#region Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/10557
            MainWindowTitleBar.RegisterPropertyChangedCallback(Microsoft.UI.Xaml.Controls.TitleBar.TitleProperty, (s, e) => UpdateWindowTitle() );
            MainWindowTitleBar.RegisterPropertyChangedCallback(Microsoft.UI.Xaml.Controls.TitleBar.SubtitleProperty, (s, e) => UpdateWindowTitle());
            UpdateWindowTitle();
#endregion
        }

        private void UpdateWindowTitle()
        {
            // This ensures the Title on the taskbar matches the window title, and narrator will read the correct title
            this.Title = MainWindowTitleBar.Title + " - " + MainWindowTitleBar.Subtitle;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-TitleBarIssues related to custom window title bars.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions