microsoft / microsoft/microsoft-ui-xaml

Setting KeyboardAccelerators on MenuBarItem in Loaded event of user control results in accelerator not working

Open
#10,977 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area-Menus bug
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

See attached repro project. Notice how Ctrl+Shift+D works while Ctrl+Shit+F does not.

[App14.zip](https://github.com/user-attachments/files/24914009/App14.zip)

### Why is this important?

We ran into this after refactoring and suddenly no shortcuts working anymore.

### Steps to reproduce the bug

1. Create MenuBar inside a UserControl
2. Add MenuBarItem in loaded event, add keyboard accelerators
3. Hit keys of accelerator on keyboard, observe it not triggering.

In the case of the repro project, Ctrl+Shift+D works while Ctrl+Shift+F does not.

**If the menubar is open, the shortcut Ctrl+Shift+F does work, if it is closed it does not.**

### Actual behavior

_No response_

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.8.3: 1.8.251106002

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached App14.zip repro and follow the MenuBar/UserControl path where the MenuBarItem and keyboard accelerators are added in the Loaded event. Reproduce the difference between Ctrl+Shift+D and Ctrl+Shift+F with the menubar closed and open. Done means the accelerator added during Loaded triggers while the menubar is closed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.