Skip to content

Commit c15b8d3

Browse files
Merge pull request #5772 from MicrosoftDocs/main
Auto Publish – main to live - 2025-09-05 05:00 UTC
2 parents 0b9a3f8 + 95dba28 commit c15b8d3

File tree

6 files changed

+105
-7
lines changed

6 files changed

+105
-7
lines changed

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9359,6 +9359,11 @@
93599359
"source_path": "hub/apps/develop/windows-integration/microsoft-copliot-key-provider.md",
93609360
"redirect_url": "/windows/apps/develop/windows-integration/microsoft-copilot-key-provider",
93619361
"redirect_document_id": false
9362+
},
9363+
{
9364+
"source_path": "hub/powertoys/command-palette/microsoft-commandpalette-extensions/ifilters_filters.md",
9365+
"redirect_url": "/windows/powertoys/command-palette/microsoft-commandpalette-extensions/ifilters_getfilters",
9366+
"redirect_document_id": false
93629367
}
93639368
]
93649369
}

hub/dev-environment/toc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ items:
184184
href: ../powertoys/command-palette/microsoft-commandpalette-extensions/ifilters.md
185185
- name: Methods
186186
items:
187-
- name: Filters
188-
href: ../powertoys/command-palette/microsoft-commandpalette-extensions/ifilters_filters.md
187+
- name: GetFilters
188+
href: ../powertoys/command-palette/microsoft-commandpalette-extensions/ifilters_getfilters.md
189189
- name: IFilterItem
190190
href: ../powertoys/command-palette/microsoft-commandpalette-extensions/ifilteritem.md
191191
- name: IForm
@@ -492,6 +492,8 @@ items:
492492
href: ../powertoys/command-palette/microsoft-commandpalette-extensions-toolkit/fallbackcommanditem_updatequery.md
493493
- name: Filter
494494
href: ../powertoys/command-palette/microsoft-commandpalette-extensions-toolkit/filter.md
495+
- name: Filters
496+
href: ../powertoys/command-palette/microsoft-commandpalette-extensions-toolkit/filters.md
495497
- name: FormContent
496498
items:
497499
- name: FormContent

hub/powertoys/command-palette/microsoft-commandpalette-extensions-toolkit/dynamiclistpage.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,36 @@ The **DynamicListPage** class is a specialized version of the [ListPage](listpag
2929
| Method | Description |
3030
| :--- | :--- |
3131
| [UpdateSearchText(String, String)](dynamiclistpage_updatesearchtext.md) | Updates the search text for the dynamic list page. |
32+
33+
## Example
34+
35+
The following example demonstrates how to create a custom dynamic list page by inheriting from the **DynamicListPage** class.
36+
37+
```csharp
38+
internal sealed partial class ServicesListPage : DynamicListPage
39+
{
40+
public ServicesListPage()
41+
{
42+
Icon = Icons.ServicesIcon;
43+
Name = "Windows Services";
44+
45+
var filters = new ServiceFilters();
46+
filters.PropChanged += Filters_PropChanged;
47+
Filters = filters;
48+
}
49+
50+
private void Filters_PropChanged(object sender, IPropChangedEventArgs args) => RaiseItemsChanged();
51+
52+
public override void UpdateSearchText(string oldSearch, string newSearch) => RaiseItemsChanged();
53+
54+
public override IListItem[] GetItems()
55+
{
56+
// ServiceHelper.Search knows how to filter based on the CurrentFilterIds provided
57+
var items = ServiceHelper.Search(SearchText, Filters.CurrentFilterIds).ToArray();
58+
59+
return items;
60+
}
61+
}
62+
```
63+
64+
The ServicesListPage utilizes a custom filter class **ServiceFilters** that inherits from the [Filters](filters.md) class to provide filtering capabilities for the list of services displayed in the command palette.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Filters Class - Command Palette Extensions Toolkit
3+
description: The Filters class is used to get and manage the filters applied to the command palette.
4+
ms.date: 09/04/2025
5+
ms.topic: reference
6+
no-loc: [PowerToys, Windows, Insider]
7+
---
8+
9+
# Filters Class
10+
11+
## Definition
12+
13+
Namespace: [Microsoft.CommandPalette.Extensions.Toolkit](microsoft-commandpalette-extensions-toolkit.md)
14+
15+
Implements **BaseObservable**, [IFilters](../microsoft-commandpalette-extensions/ifilters.md)
16+
17+
The **Filters** class is used to get and manage the filters applied to the command palette.
18+
19+
## Properties
20+
21+
| Property | Type | Description |
22+
| :--- | :--- | :--- |
23+
| CurrentFilterId | **String** | The ID of the currently applied filter. |
24+
25+
## Methods
26+
27+
| Method | Description | Returns |
28+
| :--- | :--- | :--- |
29+
| GetFilters | Gets the list of filters. This method should be overridden in derived classes to provide the actual filters. | **IFilterItem\[\]** |
30+
31+
## Example
32+
33+
The following example demonstrates how to create a custom filter class by inheriting from the **Filters** class.
34+
35+
```csharp
36+
public partial class ServiceFilters : Filters
37+
{
38+
// Constructor where CurrentFilterId is set to the default filter
39+
public ServiceFilters()
40+
{
41+
// This would be a default selection. Not providing this will cause the filter
42+
// control to display the "Filter" placeholder text.
43+
CurrentFilterId = "all";
44+
}
45+
46+
// Override GetFilters method to provide custom filters
47+
public override IFilterItem[] GetFilters()
48+
{
49+
return [
50+
new Filter() { Id = "all", Name = "All Services" },
51+
new Separator(),
52+
new Filter() { Id = "running", Name = "Running", Icon = Icons.GreenCircleIcon },
53+
new Filter() { Id = "stopped", Name = "Stopped", Icon = Icons.RedCircleIcon },
54+
new Filter() { Id = "paused", Name = "Paused", Icon = Icons.PauseIcon },
55+
];
56+
}
57+
}
58+
```

hub/powertoys/command-palette/microsoft-commandpalette-extensions/ifilters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ The **IFilters** interface is used to manage the filters in the Command Palette.
2424

2525
| Method | Description |
2626
| :--- | :--- |
27-
| [Filters()](ifilters_filters.md) | Retrieves a list of available filters in the Command Palette. This method is used to get the filters that can be applied to the items displayed in the Command Palette. |
27+
| [GetFilters()](ifilters_getfilters.md) | Retrieves a list of available filters in the Command Palette. This method is used to get the filters that can be applied to the items displayed in the Command Palette. |

hub/powertoys/command-palette/microsoft-commandpalette-extensions/ifilters_filters.md renamed to hub/powertoys/command-palette/microsoft-commandpalette-extensions/ifilters_getfilters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
title: IFilters.Filters() Method
3-
description: The Filters method retrieves a list of available filters in the Command Palette.
2+
title: IFilters.GetFilters() Method
3+
description: The GetFilters method retrieves a list of available filters in the Command Palette.
44
ms.date: 2/7/2025
55
ms.topic: reference
66
no-loc: [PowerToys, Windows, Insider]
77
---
88

9-
# IFilters.Filters() Method
9+
# IFilters.GetFilters() Method
1010

1111
## Definition
1212

1313
Namespace: [Microsoft.CommandPalette.Extensions](microsoft-commandpalette-extensions.md)
1414

15-
The **Filters** method retrieves a list of available filters in the Command Palette. This method is used to get the filters that can be applied to the items displayed in the Command Palette.
15+
The **GetFilters** method retrieves a list of available filters in the Command Palette. This method is used to get the filters that can be applied to the items displayed in the Command Palette.
1616

1717
## Returns
1818

0 commit comments

Comments
 (0)