Back to Devexpress

InfiniteSource.GetUniqueValues Event

wpf-devexpress-dot-xpf-dot-data-dot-infinitesource-7c90e164.md

latest3.7 KB
Original Source

InfiniteSource.GetUniqueValues Event

Allows you to get unique values and their counts.

Namespace : DevExpress.Xpf.Data

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public event EventHandler<GetUniqueValuesEventArgs> GetUniqueValues
vb
Public Event GetUniqueValues As EventHandler(Of GetUniqueValuesEventArgs)

Event Data

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

PropertyDescription
FilterGets the GridControl ‘s filtering. Inherited from GetUniqueValuesEventArgsBase.
PropertyNameGets the property name. Inherited from GetUniqueValuesEventArgsBase.
ResultGets or sets the result of the get unique values operation (only values).
ResultWithCountsGets or sets the result of the get unique values operation (values and their counts).
SourceGets 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.

csharp
source.GetUniqueValues += (o, e) => {
    if (e.PropertyName == "User") {
        e.ResultWithCounts = GetIssueDataQueryable().DistinctWithCounts(e.PropertyName);
    } 
    e.Result = GetIssueDataQueryable().Distinct(e.PropertyName);
};
vb
AddHandler source.GetUniqueValues, Sub(o, e)
    If e.PropertyName = "User" Then
        e.ResultWithCounts = GetIssueDataQueryable().DistinctWithCounts(e.PropertyName)
    End If
    e.Result = GetIssueDataQueryable().Distinct(e.PropertyName)
End Sub

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

InfiniteSource Class

InfiniteSource Members

DevExpress.Xpf.Data Namespace