Skip to main content

FilterBehavior.CustomUniqueValues Event

Allows you to specify unique values displayed within a filter element.

Namespace: DevExpress.Xpf.Core.FilteringUI

Assembly: DevExpress.Xpf.Grid.v24.1.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public event EventHandler<CustomUniqueValuesEventArgs> CustomUniqueValues

Event Data

The CustomUniqueValues event's data class is CustomUniqueValuesEventArgs. The following properties provide information specific to this event:

Property Description
CountedValues Gets or sets unique filter values with their counts.
FieldName Gets a name of the field.
Filter Gets the current filter criteria specified in the Filter Editor / Filter Element.
Values Gets or sets unique filter values.

Remarks

Run Demo: FilterBehavior - ViewModel Data Filtering

<dxfui:FilterBehavior x:Name="filterBehavior" ItemsSource="{x:Type local:ProductInfo}"
                      CustomUniqueValues="filterBehavior_CustomUniqueValues" /> 
void filterBehavior_CustomUniqueValues(object sender, CustomUniqueValuesEventArgs e) {
    if(e.FieldName != "CategoryName")
        throw new InvalidOperationException();
    e.CountedValues = GetCategoryUniqueValues();
}

internal IList<CountedValue> GetCategoryUniqueValues() {
    return GetProductsQueryCore()
        .GroupBy(x => x.CategoryName)
        .Select(x => new { x.Key, Count = x.Count() })
        .ToList()
        .Select(x => new CountedValue(x.Key, x.Count))
        .ToList();
}
See Also