Skip to content

CmdPal: Fix dock popup XamlRoot handling on DockControl#46305

Merged
zateutsch merged 1 commit intomainfrom
dev/jpolasek/b/46228-cmdpal-fix-dock-xamlroot-not-set-crash
Mar 24, 2026
Merged

CmdPal: Fix dock popup XamlRoot handling on DockControl#46305
zateutsch merged 1 commit intomainfrom
dev/jpolasek/b/46228-cmdpal-fix-dock-xamlroot-not-set-crash

Conversation

@jiripolasek
Copy link
Copy Markdown
Collaborator

@jiripolasek jiripolasek commented Mar 19, 2026

Summary of the Pull Request

This PR handles situations when app can crash because a popup control is being touched before XamlRoot is set.

  • Registers message handlers in DockControl only while controls are loaded.
  • Guards the edit-mode TeachingTip until the dock is rooted.
  • Sets XamlRoot for dock flyouts and tooltips before showing.
  • Ensures that tooltips in DockItemControl are set only after XamlRoot is explicitly set.
  • Unregisteres messages and CenterItems_CollectionChanged when unloaded.

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

- Registers message handlers in DockControl only while controls are loaded.
- Guards the edit-mode TeachingTip until the dock is rooted.
- Sets XamlRoot for dock flyouts and tooltips before showing.
- Ensures that tooltips in DockItemControl are set only after XamlRoot is explicitly set.
- Unregisteres messages and CenterItems_CollectionChanged when unloaded.
@jiripolasek jiripolasek added Product-Command Palette Refers to the Command Palette utility CmdPal - Dock Issues related to the Command Palette Dock 0.98.1 labels Mar 19, 2026
@jiripolasek
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses CmdPal dock crashes caused by attempting to show unparented popups (ToolTips/Flyouts/TeachingTip) before a valid XamlRoot is available, aligning popup creation/show timing with WinUI’s XamlRoot requirements.

Changes:

  • Delay/register/unregister WeakReferenceMessenger handlers and CenterItems.CollectionChanged only while DockControl is loaded; proactively close open popups on unload.
  • Guard edit-mode TeachingTip opening until the dock is rooted (XamlRoot available).
  • Ensure dock flyouts and dock item tooltips have XamlRoot set before showing/attaching.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockControl.xaml.cs Moves message/event subscriptions to Loaded/Unloaded, gates edit-mode TeachingTip, and sets XamlRoot on flyouts before ShowAt/ShowAt(button).
src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockItemControl.xaml.cs Defers tooltip popup creation until XamlRoot is available and explicitly sets ToolTip.XamlRoot before attaching.

@zateutsch zateutsch merged commit 735ea01 into main Mar 24, 2026
19 checks passed
zateutsch added a commit that referenced this pull request Mar 25, 2026
Cherry-picked commits:
- Make KBM Editor pinnable (#46482)
- CmdPal: Fix missing primary context command for late-bound items (#46131)
- CmdPal: Ensure DockWindow property cleans up after itself (#46303)
- CmdPal: Hotfix commonCallbacks array initial count to prevent negative number (#46215)
- CmdPal: Fix missing app context menu actions on the main page (#46293)
- CmdPal: Fix dock popup XamlRoot handling on DockControl (#46305)
- CmdPal: Reduce DockWindow backdrop switching and visual artifacts (#46309)
- Always On Top: The opacity should be able to configure the hotkey individually (#46410)
- [OOBE] Ensure the Settings button on the SCOOBE page opens Home, not a blank page (#46203)
- CmdPal: Fix scroller scrolling and down glyph (#46447)
- [Settings] Decouple Settings.UI.Library from PowerDisplay.Lib to fix (#46325)
@jiripolasek jiripolasek deleted the dev/jpolasek/b/46228-cmdpal-fix-dock-xamlroot-not-set-crash branch March 26, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.98.1 CmdPal - Dock Issues related to the Command Palette Dock Product-Command Palette Refers to the Command Palette utility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command Palette: Unhandled exception XamlRoot must be explicitly set for unparented popup.

4 participants