FilterControl Class

A filter editor control.

Namespace: DevExpress.Xpf.Editors.Filtering

Assembly: DevExpress.Xpf.Core.v20.1.dll

Declaration

public class FilterControl :
    Control,
    IDialogContent
Public Class FilterControl
    Inherits Control
    Implements IDialogContent

Related API Members

The following members accept/return FilterControl objects:

Remarks

NOTE

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

To enable the new filter editor in the PivotGridControl, set the PivotGridControl.UseLegacyFilterEditor property to false.

 

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

grid_FilterEditorUI

The FilterControl can control 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 will 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