FilterBehavior.CustomUniqueValues Event

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

Namespace: DevExpress.Xpf.Core.FilteringUI

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

Declaration

public event EventHandler<CustomUniqueValuesEventArgs> CustomUniqueValues
Public Event CustomUniqueValues As EventHandler(Of CustomUniqueValuesEventArgs)

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

TIP

Demo: FilterBehavior - ViewModel Data Filtering

Requires a WPF Subscription. Download

<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