Xceed Toolkit Plus for WPF v4.6 Documentation
CalculateDistinctValues Property
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridItemPropertyBase Class : CalculateDistinctValues Property
Gets or sets a value indicating whether distinct values are to be calculated for the property.
Syntax
'Declaration
 
Public Property CalculateDistinctValues As Boolean
'Usage
 
Dim instance As DataGridItemPropertyBase
Dim value As Boolean
 
instance.CalculateDistinctValues = value
 
value = instance.CalculateDistinctValues
public bool CalculateDistinctValues {get; set;}

Property Value

true if distinct values are to be calculated; false otherwise. By default (if automatic filtering is enabled), true.
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.

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 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.
<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>
Requirements

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

See Also

Reference

DataGridItemPropertyBase Class
DataGridItemPropertyBase Members