Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PagedSource.GetUniqueValues Event

Allows you to get unique values.

Namespace: DevExpress.Xpf.Data

Assembly: DevExpress.Xpf.Core.v24.2.dll

NuGet Package: DevExpress.Wpf.Core

#Declaration

public event EventHandler<GetUniqueValuesEventArgs> GetUniqueValues

#Event Data

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

Property Description
Filter Gets the GridControl‘s filtering. Inherited from GetUniqueValuesEventArgsBase.
PropertyName Gets the property name. Inherited from GetUniqueValuesEventArgsBase.
Result Gets or sets the result of the get unique values operation (only values).
ResultWithCounts Gets or sets the result of the get unique values operation (values and their counts).
Source Gets a source object that returns data.

#Remarks

Handle the GetUniqueValues event to show unique values in a column’s drop-down filter. You can also show counts of these values.

To show only unique values, get a list of these values and specify the GetUniqueValuesEventArgs.Result property.

To show unique values with their counts, get a list of these values with counts and specify the GetUniqueValuesEventArgs.ResultWithCounts property.

source.GetUniqueValues += (o, e) => {
    if (e.PropertyName == "User") {
        e.ResultWithCounts = GetIssueDataQueryable().DistinctWithCounts(e.PropertyName);
    } 
    e.Result = GetIssueDataQueryable().Distinct(e.PropertyName);
};

In the code sample above, a data source implements the IQueryable interface. You can use the GridQueryableExtensions.Distinct and GridQueryableExtensions.DistinctWithCounts methods from the DevExpress.Xpf.Grid.24.2.Extensions.dll library to obtain unique values.

Refer to the following topic for more information: Bind the WPF Data Grid to any Data Source with Virtual Sources.

See Also