You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -33,7 +35,9 @@ public override Visual Build(DemoContext context)
33
35
PopupVerticalAlignment=verticalAlignment.Value,
34
36
PopupOffsetX=offsetX.Value,
35
37
PopupOffsetY=offsetY.Value,
36
-
});
38
+
})
39
+
.QueryText(queryText)
40
+
.ClearQueryOnShow(clearQueryOnShow);
37
41
38
42
voidShowPalette()
39
43
{
@@ -44,6 +48,14 @@ void ShowPalette()
44
48
DemoUi.Title("Command palette"),
45
49
newTextBlock("Press Ctrl+P to open the command palette. Type to search, press Enter to run the top match, use arrows to navigate, or resize the window with the mouse.")
46
50
.Wrap(true),
51
+
newGroup("Query state").Content(newVStack(
52
+
newCheckBox("Clear query on show").IsChecked(clearQueryOnShow),
Copy file name to clipboardExpand all lines: site/docs/controls/commandpalette.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,7 @@ root.AddCommand(new Command
47
47
When open:
48
48
49
49
- Type to search
50
+
-`Show()` clears the previous search by default
50
51
- Press Enter to execute the currently highlighted result (the first match by default)
51
52
- Use Up/Down to navigate results
52
53
- Press Down from the search box to move directly to the next result
@@ -79,9 +80,22 @@ palette.Style(CommandPaletteStyle.Default with
79
80
80
81
`PopupWidthPercent` and `PopupHeightPercent` are optional viewport-relative sizing hints. Alignment (`Start`, `Center`, `End`, `Stretch`) and `PopupOffsetX` / `PopupOffsetY` still control where the popup appears after that size is resolved.
81
82
83
+
## Query state
84
+
85
+
`QueryText` is a bindable property on `CommandPalette`, so applications can observe, prefill, or two-way bind the current search text. `ClearQueryOnShow` controls whether `Show()` resets that query before the palette takes focus. It defaults to `true`.
0 commit comments