ThemedWindow.SearchItemDisplayMode Property
Gets or sets how to show the search box in the ThemedWindow header. This search box allows users to look for Ribbon items. This is a dependency property.
Namespace: DevExpress.Xpf.Core
Assembly: DevExpress.Xpf.Core.v24.2.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
Property Value
Type | Description |
---|---|
SearchItemDisplayMode | The mode |
Available values:
Name | Description |
---|---|
Hidden | Indicates that the search item is hidden. |
Title | The |
Right | The |
Remarks
You can show the search box in the ThemedWindow with the Ribbon control integrated. For more information on how to add a Ribbon to a ThemedWindow, refer to the following help topic: Ribbon Control – Integration With the ThemedWindow.
Initially, the search box is hidden (SearchItemDisplayMode
is set to Hidden
). Set the SearchItemDisplayMode
property to Title
or Right
to show the search box in the ThemedWindow header to the right of header content or in the top-right window corner. A user should type a search string in the text box to search against Ribbon control’s items (BarButtonItem and its descendants). The ThemedWindow looks for the search string’s occurrences among bar item content. After the drop-down list of search results appears, a user can select an action to execute it:
<dx:ThemedWindow ...
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
SearchItemDisplayMode="Title">
The ThemedWindow starts a search with a delay. You can use the SearchDelay property to specify the delay in milliseconds.
Items in the result list display icons and text specified by BarItem.Glyph and BarItem.Content properties. Each result also displays item location within the Ribbon. You can set the ShowDescriptionInSearchResults property to false
to hide locations:
ShowDescriptionInSearchResults = “True” | ShowDescriptionInSearchResults = “False” |
---|---|
You can define the ThemedWindow.SearchItemTemplate property to apply a custom template to the search item. For example, you can specify the search item’s appearance settings.
Activate Search Hotkey
You can use the Ctrl
+ F
shortcut to activate the search box. Use the SearchItemFocusShortcut property to change the shortcut.
<dx:ThemedWindow ...
SearchItemFocusShortcut="Alt+S">
Hide a Bar Item from Search
Set the attached BarItemSearchSettings.HideFromSearch property to true
for a BarButtonItem if you want to exclude it from search results.
The following example hides Button1 from search:
<dxb:BarButtonItem x:Name="Button1" Content="Button1" ItemClick="Button1_OnItemClick"
dxb:BarItemSearchSettings.HideFromSearch="True"/>
Configure the List of Results
The ThemedWindow exposes the following events that you can use to access searchable items and configure the list of search results:
- ItemsRequested
Occurs when a list of all searchable bar button items in the ThemedWindow’s Ribbon is obtained. In the event handler, use the
e.Items
property to access the items. Thee.SearchString
property returns the search query.void MainWindowOnItemsRequested(object sender, RoutedItemsArgs e) { foreach (BarButtonItem item in e.Items) { // Do something. } }
- ItemFiltering
Occurs for each searchable item in the ThemedWindow’s Ribbon so you can exclude the item based on a condition. In the event handler, use the
e.Item
property to access the item. Thee.SearchString
property returns the search query. Set thee.Visible
property tofalse
to hide the item from the results list.The following code snippet hides the button that says “Cut”:
void MainWindowOnItemFiltering(object sender, RoutedFilteringArgs e) { BarButtonItem barButtonItem = e.Item as BarButtonItem; if (barButtonItem != null && barButtonItem.Content.ToString() == "Cut") { e.Visible = false; e.Handled = true; } }
- ItemsFiltered
Occurs after events above, before the drop-down list appears. In the event handler, use the
e.ItemLinks
property to access the list of item link objects. Thee.SearchString
property returns the search query.void MainWindowOnItemsFiltered(object sender, RoutedItemLinksArgs e) { foreach (BarButtonItemLink item in e.ItemLinks) { // Do something. } }