Skip to content
Back to skills

Gum Tool Dialogs

ASecurity

Gum dialog/popup systems. Triggers: DialogService, DialogWindow, DeleteOptionsWindow, dialog scrolling/layout, adding new dialog types, ShowMessage/ShowYesNoMessage, mocking IDialogService in unit tests.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
designgoc#shellreacttesting

Works with

  • cli

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add vchelaru/Gum --skill gum-tool-dialogs --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gum Tool Dialogs?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gum Tool Dialogs
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vchelaru-gum-tool-dialogs/badge)](https://www.skillsdirectory.com/skills/vchelaru-gum-tool-dialogs)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gum-tool-dialogs
description: Gum dialog/popup systems. Triggers: DialogService, DialogWindow, DeleteOptionsWindow, dialog scrolling/layout, adding new dialog types, ShowMessage/ShowYesNoMessage, mocking IDialogService in unit tests.
---

# Gum Dialog Systems Reference

## Two Separate Systems

Gum has **two independent dialog systems**. Knowing which one is involved is critical before making changes.

Both heads implement the same `IDialogService` contract (`Tools/Gum.Presentation/Dialogs/`), and every dialog view model lives in `Gum.Presentation`. The WPF mechanics in this section describe the frozen WPF head (`Gum/`); the shipped tool is the Avalonia head, whose equivalents are in the "Avalonia head" section below.

### 1. DialogService System (MVVM, most dialogs)

Used by: message popups, yes/no confirmations, text input, choice selection, plugin management, import dialogs.

**Flow**: `DialogService` creates a `DialogWindow`, sets its `DataContext` to a view model. The `Dialog` control inside uses a `DialogTemplateSelector` to resolve the view model type to a `UserControl` view. After the view loads, `Dialog.OnContentChanged` binds attached properties from the view up to the `Dialog` control via deferred dispatch (`DispatcherPriority.Loaded`).

**Key attached properties on views** (set in XAML on the UserControl):
- `Dialog.DialogTitle` — window title
- `Dialog.Actions` — custom button area (replaces default OK/Cancel)
- `Dialog.AuxiliaryActions` — extra buttons on the left side (e.g. Browse)
- `Dialog.ScrollContent` — `true` (default) enables outer ScrollViewer; `false` disables it so the view can manage its own scrolling (used by ImportFromGumxView)

**View resolution**: `DialogViewResolver` maps view model types to views by naming convention (`FooViewModel` -> `FooView`) or by `[Dialog(typeof(VM))]` attribute. Scans assemblies lazily and caches results. It always scans the VM's own assembly first, then - if unresolved - falls back to `IDialogViewAssemblyProvider` (default: every assembly currently loaded in the process) to find a VM whose View lives elsewhere (e.g. a `DialogViewModel` relocated into the headless `Gum.Presentation` assembly, paired with a View that stays in the Gum tool assembly or a dynamically-loaded plugin). **The fallback only works via `[Dialog(typeof(VM))]`** - naming-convention matching pairs a VM+View found within the *same* scanned assembly, so it can never bridge a cross-assembly pairing. Attribute the View before moving its VM out of the tool assembly. Plugin dialog views live in the WPF head (`Gum/PluginViews/<Plugin>/`) so the plugin assemblies stay WPF-free. The Avalonia head has no resolver: it maps each view model to its view in `Tool/Gum.Avalonia/Dialogs/DialogViewRegistry.cs` and binds the window title to the view model's `Title`.

**Window sizing**: `DialogWindow` starts with `SizeToContent="WidthAndHeight"`. After content loads, `Dialog.OnContentChanged` switches to `SizeToContent.Manual` and clears the view's fixed Width/Height (sets to NaN), allowing the window to be resizable. `DialogService.CreateDialogWindow` sets `MaxHeight` to the owner window's `ActualHeight`. `IDialogService` has no size option: a dialog that must open at a fixed size (the import dialog, whose tree would otherwise grow the window) sets `Width`/`Height` on its view, which becomes the window's starting size. In the Avalonia head a fixed `Height` never shrinks, so a view that should still fit a short screen sets `DialogWindow.SetPreferredHeight` instead (the import and Plugins dialogs).

### 2. DeleteOptionsWindow (standalone, code-behind)

Used by: delete confirmation only (`DeleteLogic.ShowDeleteDialog`).

**Why it exists separately**: The delete dialog needs runtime UI composition — plugins inject checkboxes and options into a `StackPanel` (e.g., "Delete associated files?", "Remove child instances?"). This cannot be done through the MVVM template system.

**Never give an injected control an explicit `Width`.** WPF centers an element that has a fixed size inside space it would otherwise stretch into, so a fixed-width checkbox renders indented relative to its neighbours, and a label longer than that width is clipped rather than wrapped. Being standalone, this window gets none of `Dialog.OnContentChanged`'s fixed-size clearing described above. Set `HorizontalAlignment.Left` instead.

**A checkbox label only wraps with an explicit `MaxWidth` on its own `TextBlock`.** The themed `CheckBox` template (`Themes/Frb.Styles.Defaults.xaml`) measures its `ContentPresenter` in an `Auto` column, which supplies no width to wrap against, so `TextWrapping` alone is a no-op that widens the window instead. This applies to every checkbox in the tool, not just this dialog.

**Flow**: `DeleteLogic` (headless, `Tools/Gum.Presentation/Managers/DeleteLogic.cs`) calls the head's `IDeleteDialogService`. Plugins contribute options in one of two ways:

- **Neutral (use this):** handle `PluginBase.DeleteOptionsShow(DeleteOptionsDialogViewModel, Array)` and add a `DeleteOptionCheckboxViewModel` to `dialog.CheckBoxes` or a pick-one `DeleteOptionChoiceViewModel` to `dialog.Choices`; read the user's choice back in `DeleteOptionsConfirmed`. Dispatch goes through `IDeletePluginNotifier.ShowDeleteOptions`/`ConfirmDeleteOptions`. `DeleteObjectPlugin` and the State Animation plugin use this.
- **WPF-only (legacy):** `WpfPluginBase.DeleteOptionsWindowShow`/`DeleteConfirmed` hand the plugin the `DeleteOptionsWindow` to add controls to `MainStackPanel`. Only CodeOutputPlugin still does this.

The WPF `DeleteDialogService` creates the `DeleteOptionsWindow`, fires the WPF event (concrete `PluginManager.ShowDeleteDialog()`), then the neutral one, renders the neutral options into `MainStackPanel` (`DeleteOptionCheckboxExtensions.ToCheckBox`/`ToGroupBox`, bound two-way), and calls `ShowDialog()`. The Avalonia head's `AvaloniaDeleteDialogService` shows the `DeleteOptionsDialogViewModel` through `IDialogService` (`DeleteOptionsDialogView`), so under Avalonia this dialog **is** part of the MVVM system. `DeleteDialogService` depends on the concrete `PluginManager` for the WPF-typed pair, which lives only on the concrete class.

**Not managed by DialogService** — no view model, no template selection, no attached property binding. Changes to `DialogWindow.xaml` or `Dialog.cs` have **zero effect** on this window.

## Key Files

| File | System | Purpose |
|------|--------|---------|
| `Gum/Services/Dialogs/DialogService.cs` | MVVM | Creates and shows DialogWindow instances |
| `Gum/Services/Dialogs/DialogWindow.xaml` | MVVM | Window chrome, layout template with ScrollViewer + button footer |
| `Gum/Services/Dialogs/Dialog.cs` | MVVM | ContentControl with attached properties and template selector |
| `Gum/Services/Dialogs/DialogViewResolver.cs` | MVVM | Maps view model types to view types; falls back to scanning its own (tool) assembly for a relocated VM's `[Dialog]`-attributed View |
| `Tools/Gum.Presentation/Dialogs/DialogViewModel.cs` | MVVM | Base class with affirm/negative commands and RequestClose event (shared by both heads) |
| `Gum/Gui/Windows/DeleteOptionsWindow.xaml` | Standalone | Delete confirmation window layout |
| `Gum/Gui/Windows/DeleteOptionsWindow.xaml.cs` | Standalone | Code-behind with plugin-accessible StackPanel |
| `Gum/Services/Dialogs/DeleteDialogService.cs` | Standalone | Creates and shows DeleteOptionsWindow; calls the concrete `PluginManager` |
| `Tools/Gum.Presentation/Managers/DeleteLogic.cs` | Standalone | Orchestrates the delete flow via `IDeleteDialogService` |
| `Tool/Gum.Avalonia/Dialogs/AvaloniaDialogService.cs` | MVVM (Avalonia) | The Avalonia head's `IDialogService` |
| `Tool/Gum.Avalonia/Dialogs/DialogWindow.cs` | MVVM (Avalonia) | Window chrome, OK/Cancel row, `DialogTitle` / `AuxiliaryActions` attached properties |
| `Tool/Gum.Avalonia/Dialogs/DialogViewRegistry.cs` | MVVM (Avalonia) | Maps each view model type to its C# view factory |
| `Tool/Gum.Avalonia/Dialogs/AvaloniaDeleteDialogService.cs` | Delete (Avalonia) | Shows `DeleteOptionsDialogViewModel` through `IDialogService` |

## Avalonia head

The Avalonia head (`Tool/Gum.Avalonia`) has its own synchronous `IDialogService`
(`Dialogs/AvaloniaDialogService.cs`, a nested dispatcher loop per dialog). A new dialog or file picker is owned by the topmost open `DialogWindow` (`AvaloniaDialogService.CurrentOwner`), and pickers go through `IFilePickers` so tests can fake them. It does not scan
assemblies: `Dialogs/DialogViewRegistry.cs` maps each `DialogViewModel` type to a C# view factory
(`Register<TViewModel>(() => new SomeView())`; a registration covers subclasses, so every
`GetUserStringDialogBaseViewModel` shares one view). `DialogWindow` supplies the OK/Cancel row from
the VM; a view sets `DialogWindow.SetDialogTitle(this, "...")` and
`DialogWindow.SetAuxiliaryActions(this, control)` where the WPF view used `Dialog.DialogTitle` and
`Dialog.AuxiliaryActions`. `Tests/Gum.Avalonia.Tests/DialogViewRegistryTests` fails when a concrete
`DialogViewModel` in `Gum.Presentation` has no registered view and no named owner in its
`OwnedElsewhere` list, so **adding a dialog VM means registering its Avalonia view in the same PR**.

`DialogWindow` wraps the view in a vertical `ScrollViewer` and `FitHeightToScreen` caps the window
at the screen's working area, so a tall view scrolls and the buttons stay reachable. A list or tree
inside a view gets unbounded height from that scroller, so it needs its own `MaxHeight`, or the view
sets `DialogWindow.SetScrollContent(this, false)` (twin of WPF's `Dialog.ScrollContent="False"`) to
take the bounded height itself and scroll only one part, as `GetUserStringDialogView` scrolls its
message while keeping the text box pinned.

**The Settings window** (Edit > Settings...) is one `SettingsDialogViewModel` with a close-only button row
(`AffirmativeText = "Close"`, `NegativeText = null`); changes apply as they are made, so a page has no
Cancel. Its pages come from `ISettingsPageRegistry` plus Application > General, Appearance and Plugins,
which the view model builds on each open; see `gum-tool-plugins` for adding a page. A dialog view model
can be reused as a page (`ThemingDialogViewModel`, `PluginsDialogViewModel`): `SettingsPageViewRegistry`
embeds its dialog view and moves the view's `DialogWindow.SetAuxiliaryActions` buttons under it, because
the page has no button row of its own.

**A page view is plain content that grows; the window scrolls it.** `SettingsDialogView` puts the page's
title, scope line and view in one `ScrollViewer`, so everything but the page list and Close scrolls as one
page. A page therefore must not hold a list box, scroller or fixed height of its own (a `DataUiGrid` is fine,
since it grows in an outer scroller). Only a reused view that already scrolls internally registers with
`scrollsItself: true`, and then gets the bounded height under a fixed title (the Plugins page).

A dialog with nothing to type into can set `AnswersOnAccessKeyAlone` so the bare access-key letter
of its "_Yes"/"_No" text answers it (`DialogViewModel.TryAnswerFromAccessKey`).

**Menu actions run after the menu closes.** Every Avalonia menu item (main menu, context menus,
the Variables tab, the Animations tab, the Standards palette) invokes its action through
`MenuItemActions.InvokeAfterClose` (`Tool/Gum.Avalonia/Shell/MenuItemActions.cs`). The dialog
service is synchronous (a nested dispatcher loop), so an action invoked inside the click handler
opened its dialog while the menu was still open, and the menu's light-dismiss swallowed the first
click into the dialog. A new menu site must use the same helper; `MenuBuilderTests` pins it.

The macOS menu bar needs more than a dispatcher post: its click arrives while AppKit is still
tracking the menu, and Avalonia's dispatcher runs during tracking, so a dialog opened from a plain
post is ordered in but never brought to the front or made key. `AvaloniaNativeMenuBuilder` takes an
`invokeAfterClick` scheduler, and the shell passes `Shell/MacOS/MenuTrackingScheduler.InvokeAfterTracking`
(a CoreFoundation timer in the default run-loop mode, which cannot fire until tracking ends). A new
native menu must pass it too.

## Startup failures

Startup-path code never lets a best-effort side effect (marker file, sentinel, log) throw and abort startup; route it through `BestEffortFile.TryRun` (`Tools/Gum.ProjectServices/Diagnostics/BestEffortFile.cs`), as `LastProjectLoadMarker` and `FreezeDiagnosticsInbox` do. A user-visible startup failure is a normal closable window with Copy and Close (`StartupFailurePanel`), never a full-window text dump.

## Common Pitfalls

**Wrong system**: The most common mistake is modifying `DialogWindow.xaml` or `Dialog.cs` expecting it to affect the delete dialog. Always verify which system shows the dialog you're fixing.

**File copy prompt**: The "copy or reference?" dialog shown when a SourceFile/Font path outside the project folder is assigned lives in `SetVariableLogic.AskIfShouldCopy` (`Tools/Gum.Presentation/Plugins/InternalPlugins/VariableGrid/SetVariableLogic.cs`), triggered via `ReactIfChangedMemberIsSourceFile` — not in the drag-drop layer.

**ScrollViewer behavior**: The `Dialog` template wraps content in a ScrollViewer. With `Auto` scrolling, child controls get infinite available height during WPF measure — so internal scroll viewers (like a TreeView) won't scroll. Set `Dialog.ScrollContent="False"` on views that need bounded height for internal scrolling.

**Deferred binding**: `Dialog.OnContentChanged` binds attached properties at `DispatcherPriority.Loaded`, not immediately. Code that reads these values before the dispatch fires will see defaults.

## Testing Dialog Interactions (mocking IDialogService)

`IDialogService` exposes one message primitive: `ShowMessage(message, title?, MessageDialogStyle?)`, returning a `MessageDialogResult` enum (`Affirmative` / `Negative` / `Canceled`; `Negative == 0` is the unmocked Moq default → a `Mock<IDialogService>` returns "No" unless you set it up). The friendly helpers — `ShowYesNoMessage`, `ShowChoices`, etc. — are **extension methods** in `IDialogServiceExtensions` (`Gum.Presentation`), so a Moq mock can only `Setup`/`Verify` the underlying `ShowMessage`. A Yes/No prompt arrives as `ShowMessage(msg, title, MessageDialogStyle.YesNo)`.

Gotcha: `MessageDialogStyle` is a **class**, and `.Ok` / `.YesNo` / `.OkCancel` each `new` up a fresh instance with no equality override — you cannot match a specific style by reference or equality. Distinguish a styled prompt (Yes/No, OK/Cancel) from a plain informational popup by **`style != null` vs `style == null`** — a bare `ShowMessage(msg)` passes `null` — or by inspecting `AffirmativeText`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in design →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.