AutoFilterMode Property
See Also  Example
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridCollectionViewSource Class : AutoFilterMode Property

Gets or sets a value indicating how automatic filtering of the data items will be performed. This feature is available only in the Professional Edition

Syntax

Visual Basic (Declaration) 
Public Property AutoFilterMode As AutoFilterMode
C# 
public AutoFilterMode AutoFilterMode {get; set;}

Return Value

An AutoFilterMode value indicating how automatic filter of the data items will be performed. By default, None indicating that no automatic filtering will be used.

Member Description
None The data items will not be filtered.
And The data items will be filtered according to all the filtering criteria defined by each column. If a data item matches all the criteria, it will be included.
Or The data items will be filtered according to at least one of the filtering criteria defined by the columns. If a data item matches at least one criteria, it will be included.

Example

All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to enable automatic filtering, disabling it for the columns that will not support it and filtering the distinct values of the ShipCity column.
XAMLCopy Code
<Grid> 
  <Grid.Resources> 
  <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" 
                                     Source="{Binding Source={x:Static Application.Current}, 
                                                      Path=Orders}" 
                                     AutoFilterMode="And" 
                                     DistinctValuesConstraint="Filtered" 
                                     AutoCreateItemProperties="False">       
       <xcdg:DataGridCollectionViewSource.ItemProperties> 
         <xcdg:DataGridItemProperty Name="ShipCountry" 
                                          Title="Country"/> 
         <xcdg:DataGridItemProperty Name="ShipCity" 
                                   Title="City"/> 
        <xcdg:DataGridItemProperty Name="ShipAddress" 
                                   Title="Address"/> 
        <xcdg:DataGridItemProperty Name="ShipPostalCode" 
                                   Title="Postal Code"/> 
         <xcdg:DataGridItemProperty Name="ShipName" 
                                   Title="Name" 
                                   CalculateDistinctValues="False"/> 
         <xcdg:DataGridItemProperty Name="OrderDate" 
                                   Title="Order Date" 
                                   CalculateDistinctValues="False"/>                
         <xcdg:DataGridItemProperty Name="Freight" 
                                   CalculateDistinctValues="False"/> 
      </xcdg:DataGridCollectionViewSource.ItemProperties> 
    </xcdg:DataGridCollectionViewSource>        
  </Grid.Resources> 
  <xcdg:DataGridControl x:Name="OrdersGrid" 
                        ItemsSource="{Binding Source={StaticResource cvs_orders}}"/> 
</Grid>

Remarks

If a column does not need to support automatic filtering, it is recommended to set its corresponding DataGridItemProperty's CalculateDistinctValues or the DataGridCollectionViewSource's DefaultCalculateDistinctValues properties to false.

Notes

If a column displays a custom type, automatic filtering will not function properly for that column unless the type implements the IComparable interface.

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.5

See Also