wpf-devexpress-dot-xpf-dot-editors-2f3b5622.md
A search control.
Namespace : DevExpress.Xpf.Editors
Assembly : DevExpress.Xpf.Core.v25.2.dll
NuGet Package : DevExpress.Wpf.Core
[DXLicenseWpfEditors]
public class SearchControl :
Control
<DXLicenseWpfEditors>
Public Class SearchControl
Inherits Control
The following members return SearchControl objects:
The Search Control provides an easy way for end users to locate information within data editors (list boxes, combo boxes, etc). To execute a search, enter the text in the search box. Data editors bound to the Search Control will display those records that have matching values.
Various options are available to control the display and behavior of the Search Control. You can specify search columns, choose between automatic and manual search modes, optionally display control buttons, etc.
Tip
Topic : Data Grid - Search
Single keyword.
To search for a string that contains a space character, specify this string in quotation marks.
Without quotation marks, words separated by the space character are treated as individual conditions.
To search against a specific column, precede a search string with the column’s display name plus a colon character.
Precede a condition with “+” to display only records that match this condition. The “+” specifier allows you to implement the logical And operator. There should be no space character between the “+” sign and the condition.
Precede a condition with “-“ to exclude records that match this condition from the result set. There should be no space between the “-“ sign and the condition.
You can combine different operators.
This example shows how to use the SearchControl to locate required items displayed within a list box. To execute a search, enter a text within the Find box, and the list box linked to the Search Control will display those records that have matching values.
<Window x:Class="ListBoxFilteringUsingSearchPanel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<dxe:SearchControl x:Name="searchControl" Grid.Row="0" Margin="10"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
FilterCondition="Contains"
FilterByColumnsMode="Custom">
<dxe:SearchControl.ColumnProvider>
<dxe:SelectorEditColumnProvider>
<dxe:SelectorEditColumnProvider.CustomColumns>
<sys:String>Name</sys:String>
</dxe:SelectorEditColumnProvider.CustomColumns>
</dxe:SelectorEditColumnProvider>
</dxe:SearchControl.ColumnProvider>
</dxe:SearchControl>
<dxe:ListBoxEdit Name="listBox" Grid.Row="1" Margin="10"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
DisplayMember="Name" ValueMember="ID"
FilterCriteria="{Binding FilterCriteria, ElementName=searchControl}">
</dxe:ListBoxEdit>
</Grid>
</Window>
using System.Windows;
namespace ListBoxFilteringUsingSearchPanel {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
listBox.ItemsSource = Staff.GetStaff();
}
}
}
Imports System.Windows
Namespace ListBoxFilteringUsingSearchPanel
Public Partial Class MainWindow
Inherits Window
Public Sub New()
Me.InitializeComponent()
Me.listBox.ItemsSource = GetStaff()
End Sub
End Class
End Namespace
Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Control SearchControl
See Also