If a column does not need to support automatic filtering, it is recommended to set its corresponding DataGridItemProperty'sCalculateDistinctValues to false or set the DataGridCollectionViewSource or DataGridDetailDescription'sDefaultCalculateDistinctValues properties to false and only set CalculateDistinctValues to true for the item properties that will support auto-filtering
By default, the values that are displayed in the auto-filter drop down represent the distinct values as they are extracted from the underlying data source; however, custom distinct values can be provided for one or more item properties rather than the originally-extracted distinct values by handling their QueryDistinctValue event and returning the custom value.
Example
All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The first example demonstrates how to provide the ShipCountry column with a new style for its associated AutoFilterControl that will only allow single selection.
The second example demonstrates how to use a ComboBox as an auto-filter control to automatically filter the content of the ShipCountry column. ComboBox controls do not support multiple selections; therefore, the values of the target column will only be filtered by 1 value.
Since, by default, the auto-filter control in the column-manager-cell drop downs support multiple selections, it is recommended to deactivate the drop down by setting the AllowAutoFilter property of the ColumnManagerRow to false to hide the column-manager cells' auto-filter controls and prevent unexpected synchronization behavior between the controls that have the same auto-filter target column or different selection modes.
Gets a value indicating whether the auto-filter control contains the distinct values of the AutoFilterColumn, indicating that it can be automatically filtered.
When deriving from the AutoFilterControl class, PrepareDefaultStyleKey must be overridden in order to support dynamic style (view or theme modifications) changes.
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2