Skip to main content
A newer version of this page is available. .

ChartBase.SelectionChanged Event

Occurs when the chart selection is changed.

Namespace: DevExpress.WinUI.Charts

Assembly: DevExpress.WinUI.Charts.v21.1.dll

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 the list of currently selected objects. 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 total area of the 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