| Visual Basic (Declaration) | |
|---|---|
<TemplatePartAttribute(Name="PART_DistinctValuesHost", Type=System.Windows.Controls.Primitives.Selector)> Public Class AutoFilterControl Inherits Control Implements ISupportInitialize, IFrameworkInputElement, IInputElement, IWeakEventListener, IHaveResources, IAnimatable, DUCE.IResource | |
| C# | |
|---|---|
[TemplatePartAttribute(Name="PART_DistinctValuesHost", Type=System.Windows.Controls.Primitives.Selector)] public class AutoFilterControl : Control, ISupportInitialize, IFrameworkInputElement, IInputElement, IWeakEventListener, IHaveResources, IAnimatable, DUCE.IResource | |
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 provide the ShipCountry column with a new style for its associated AutoFilterControl that will only allow single selection.
| XAML | Copy Code |
|---|---|
<Grid> | |
The following 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.
| XAML | Copy Code |
|---|---|
<Grid> | |
If a column does not need to support automatic filtering, it is recommended to set its corresponding DataGridItemProperty's CalculateDistinctValues to false or set the DataGridCollectionViewSource or DataGridDetailDescription's DefaultCalculateDistinctValues properties to false and only set CalculateDistinctValues to true for the item properties that will support auto-filtering
If a column displays a custom type, automatic filtering will not function properly for that column unless the type implements the IComparable interface.
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Control
Xceed.Wpf.DataGrid.AutoFilterControl
Supported Operating Systems: Windows Server 2003 Service Pack 1; Windows Vista; Windows XP Service Pack 2


~217.gif)

~217.gif)
Copy Code