Skip to main content

ChartBase.SelectionChanged Event

Occurs when the chart selection is changed.

Namespace: DevExpress.WinUI.Charts

Assembly: DevExpress.WinUI.Charts.v23.2.dll

NuGet Package: DevExpress.WinUI

Declaration

public event ChartElementSelectionChangedEventHandler SelectionChanged

Event Data

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

Property Description
ChangedElement Returns the chart element that is currently selected or deselected.
IsSelected Returns the selection state of the chart element that is currently selected or deselected.
Selection Returns a list of items that are selected in a chart. Inherited from ElementSelectionChangedEventArgs.

Remarks

The ChartBase.SelectionChanged event occurs when a user selects or deselects series points. Use the e.Selection property to obtain selected items. The following example calculates the total area of selected countries:

private void chartOfCountriesArea_SelectionChanged(object sender, ChartElementSelectionChangedEventArgs e) {
    double totalArea = 0;
    foreach (CountryStatisticInfo point in e.Selection) {
        totalArea += point.AreaMSqrKilometers;
    }
    selectedItemsText.Text = String.Format("Total area of ​​selected countries: {0}", totalArea);
}

Use the e.ChangedElement property to get the series point whose selection state is changed. The e.IsSelected property returns this selection state. The following code calls a custom UpdateStatistics method for the last selected series point:

private void chartOfCountriesArea_SelectionChanged(object sender, ChartElementSelectionChangedEventArgs e) {
    selectedItemsText.Text = String.Format("Total area of ​​selected countries: {0}", totalArea);
    if (e.IsSelected) {
        UpdateStatistics((CountryStatisticInfo)e.ChangedElement);
    }
}
See Also