.NET MAUI Chart Selection Behavior
The Selection behavior of the Chart handles selecting, deselecting, and reporting the selection of either data points or series. In other words, the selection behavior can target data points, series or both if required.
Features
The Chart exposes properties, methods, events, and commands for handling its Selection behavior.
Properties
The Selection behavior supports the following properties:
-
DataPointSelectionMode
—Gets or sets theChartSelectionMode
that controls the selection behavior of the data points within the chart series. The available values are:-
None
-
Single
-
Multiple
-
-
SeriesSelectionMode
—Gets or sets theChartSelectionMode
that controls the selection behavior of the series within the plot area. The available values are:-
None
-
Single
-
Multiple
-
-
SelectedPoints
—Retrieves all the points from all currently selected series within the chart plot area. -
SelectedSeries
—Retrieves all currently selected series instances within the plot area.
Methods
The Selection behavior supports the ClearSelecton()
method, which removes the current selection within the chart.
Events
The Selection behavior supports the SelectionChanged
event, which occurs when a selection has been made.
Commands
The Selection behavior supports the Commands
selection.
Example
The following example shows how the Selection behavior of the Chart works with a Command
:
1. Create the business objects:
2. Create a ViewModel
:
3. Declare a RadCartesianChart
in XAML:
The following image shows how the selection looks: