microsoft / microsoft/microsoft-ui-xaml

TitleBar with IconSource resets the mouse cursor to the arrow on every layout pass

Open
#11,942 0 comments 0 reactions 0 assignees View on GitHub
bug needs-triage
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When a `TitleBar` has `IconSource` set (and is used as the window title bar through `ExtendsContentIntoTitleBar` + `SetTitleBar`), the mouse cursor is reset to the default arrow whenever a layout pass happens anywhere in the window while the pointer is not moving.

This affects every cursor in the window: the I-beam of a `TextBox`, cursors set with `UIElement.ProtectedCursor`, etc. The correct cursor comes back only when the mouse is physically moved, so any UI that updates continuously (data bindings, a live image, `ScrollView` animations) shows the arrow most of the time while the pointer rests on it.

Without `IconSource`, the cursor behaves correctly.

### Why is this important?

Setting `TitleBar.IconSource`, the standard way to show the app icon, breaks the mouse cursor in the whole window: any UI that updates (bindings, live images, scroll animations) resets `TextBox` I-beams and custom `ProtectedCursor` cursors to the arrow. App code can't restore the cursor until the mouse moves, and the cause is very hard to trace.

### Steps to reproduce the bug

1. Create an unpackaged WinUI 3 app with this `MainWindow`:

```xml













```

```csharp
public sealed partial class MainWindow : Window
{
private readonly DispatcherTimer _timer = new() { Interval = TimeSpan.FromMilliseconds(500) };
private int _updates;

public MainWindow()
{
InitializeComponent();

ExtendsContentIntoTitleBar = true;
SetTitleBar(AppTitleBar);

// Any layout pass triggers the cursor reset: a changing text is enough
_timer.Tick += (_, _) => ChangingText.Text = $"Text update #{++_updates}";
_timer.Start();
}

private void OnIconSourceCheckBoxClick(object sender, RoutedEventArgs e) =>
AppTitleBar.IconSource = IconSourceCheckBox.IsChecked == true ? new FontIconSource { Glyph = "" } : null;
}
```

2. Run the app, move the pointer over the `TextBox` and then keep the mouse still.
3. Observe the cursor at every text update (every 0.5 s).
4. Uncheck "TitleBar.IconSource set" and repeat step 2.

### Actual behavior

With `IconSource` set, the cursor turns into the arrow at every text update and stays so until the mouse is moved. With `IconSource` cleared (step 4), the cursor stays the I-beam.

Setting the cursor again from the app does not help: once reset, the displayed cursor does not change with `ProtectedCursor`, `InputPointerSource.Cursor` or Win32 `SetCursor` until a real mouse move.

### Expected behavior

The cursor stays the I-beam while the pointer rests on the `TextBox`, whatever happens elsewhere in the window.

### Screenshots

_No response_

### NuGet package version

Windows App SDK 2.5.1 (also reproduced with 2.2.0).

### Windows version

Windows 11 (25H2): Build 26200

### Additional context

[CursorRepro.zip](https://github.com/user-attachments/files/32392465/CursorRepro.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the MainWindow repro in the attached CursorRepro.zip, especially the TitleBar.IconSource, SetTitleBar, and DispatcherTimer setup. Trace the layout and cursor behavior with IconSource enabled and disabled; done means the TextBox keeps its I-beam and other custom cursors during layout updates without mouse movement.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.