Skip to main content
A newer version of this page is available. .

FilterControl Class

The legacy Filter Editor control allows users to build complex filter criteria.

Namespace: DevExpress.Xpf.Editors.Filtering

Assembly: DevExpress.Xpf.Core.v21.2.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public class FilterControl :
    Control,
    IDialogContent

The following members return FilterControl objects:

Remarks

The FilterControl is a visual control that allows users to build filter criteria. Users can add an unlimited number of filter conditions and use logical operators to group them:

grid_FilterEditorUI

Note

The GridControl and TreeListControl use the new filter editor starting from v19.1. To enable the legacy filter editor in the GridControl / TreeListControl, set the DataViewBase.UseLegacyFilterEditor property to true.

To enable the legacy filter editor in the PivotGridControl, set the PivotGridControl.UseLegacyFilterEditor property to true.

 

The FilterControl manages data filtering for the DXGrid control via the DataControlBase.FilteredComponent property, a DataTable component, and any object which implements the DevExpress.Xpf.Editors.Filtering.IFilteredComponent interface. To specify the object to which the FilterControl should supply filter criteria, use the FilterControl.SourceControl property.

Note

Note that although the DXGrid control provides an embedded Filter Editor, you can still use a separate FilterControl, with the DXGrid control to provide standalone filter editing.

After a source control has been assigned to the FilterControl via the FilterControl.SourceControl property, the filter columns and editors used to edit operand values are automatically retrieved from the source control. Filter columns are stored within the FilterControl.FilterColumns collection.

The filter expression built via the FilterControl can be obtained via the FilterControl.FilterCriteria property. This property can also be used to specify filter criteria in code.

To apply a filter created in the FilterControl to the grid control using the FilterControl.ApplyFilter method, use binding for the FilterControl.FilterCriteria property, as shown in the code snippet below.

<dxe:FilterControl x:Name="filterEditor" 
                   SourceControl="{Binding ElementName=filterGrid, Path=FilteredComponent}"
                   FilterCriteria="{Binding ElementName=filterGrid, Path=FilterCriteria, Mode=TwoWay}"/>

Changes made to the source control’s filter criteria are automatically tracked by the FilterControl. Each time the source control’s filtering settings are modified by a user or in code, the FilterControl automatically reflects the changes. Note that filter criteria built via the FilterControl are not automatically applied to the bound source control. To apply the current filter criteria to the source control, use the FilterControl.ApplyFilter method.

The code sample below shows the FilterControl. The Apply Filter button with the ApplyFilterCommand command allows you to apply filter criteria specified in the FilterControl to a bound control.

<dxe:FilterControl x:Name="control" />
<!-- -->
<Button Content="Apply Filter" Command="{Binding ElementName=control, Path=ApplyFilterCommand}"/>

The FilterControl can be used in unbound mode, when it’s not bound to any source control (the FilterControl.SourceControl property is set to null). In this mode, specific columns must be added to the FilterControl.FilterColumns collection manually. An end-user will be able to construct filter criteria using these columns. To get the current filter criteria, use the FilterControl.FilterCriteria property.

Note

A FilterControl is not intended to be used in Windows Forms hosted applications.

See Also