Class ChartSelectionBehavior
The ChartSelectionBehavior is the base class for DataPointSelectionBehavior, and SeriesSelectionBehavior.
Inheritance
Inherited Members
Namespace: Syncfusion.Maui.Charts
Assembly: Syncfusion.Maui.Charts.dll
Syntax
public abstract class ChartSelectionBehavior : ChartBehavior, IParentThemeElement, IThemeElement
Constructors
ChartSelectionBehavior()
Initializes a new instance of the ChartSelectionBehavior class.
Declaration
public ChartSelectionBehavior()
Fields
SelectedIndexesProperty
Identifies the SelectedIndexes bindable property.
Declaration
public static readonly BindableProperty SelectedIndexesProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
SelectedIndexProperty
Identifies the SelectedIndex bindable property.
Declaration
public static readonly BindableProperty SelectedIndexProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
SelectionBrushProperty
Identifies the SelectionBrush bindable property.
Declaration
public static readonly BindableProperty SelectionBrushProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TypeProperty
Identifies the Type bindable property.
Declaration
public static readonly BindableProperty TypeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Properties
SelectedIndex
Gets or sets the index of segment or series to be selected in selection behavior.
Declaration
public int SelectedIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | This property takes System.Int32 value and its default value is -1. |
Remarks
This property value is used only when Type is set to Single or SingleDeselect.
Examples
<chart:SfCircularChart>
<!--omitted for brevity-->
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
<chart:PieSeries.SelectionBehavior>
<chart:DataPointSelectionBehavior SelectedIndex="3" SelectionBrush = "Red" />
</chart:PieSeries.SelectionBehavior>
</chart:PieSeries>
</chart:SfCircularChart>
SelectedIndexes
Gets or sets the list of segments or series to be selected in selection behavior.
Declaration
public List<int> SelectedIndexes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.Int32> | This property takes the list of System.Int32 values and its default value is null. |
Remarks
Examples
<chart:SfCircularChart>
<!--omitted for brevity-->
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
<chart:PieSeries.SelectionBehavior>
<chart:DataPointSelectionBehavior Type="Multiple" SelectedIndexes="{Binding indexes}" SelectionBrush = "Red" />
</chart:PieSeries.SelectionBehavior>
</chart:PieSeries>
</chart:SfCircularChart>
SelectionBrush
Gets or sets the selection brush color for selection behavior.
Declaration
public Brush SelectionBrush { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | This property takes Microsoft.Maui.Controls.Brush value and its default value is null. |
Examples
<chart:SfCircularChart>
<!--omitted for brevity-->
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
<chart:PieSeries.SelectionBehavior>
<chart:DataPointSelectionBehavior SelectionBrush = "Red" />
</chart:PieSeries.SelectionBehavior>
</chart:PieSeries>
</chart:SfCircularChart>
Type
Gets or sets the selection mode for selection behavior.
Declaration
public ChartSelectionType Type { get; set; }
Property Value
Type | Description |
---|---|
ChartSelectionType | This property takes ChartSelectionType as value and its default value is Single. |
Examples
<chart:SfCircularChart>
<!--omitted for brevity-->
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue">
<chart:PieSeries.SelectionBehavior>
<chart:DataPointSelectionBehavior Type="Multiple" SelectionBrush = "Red" />
</chart:PieSeries.SelectionBehavior>
</chart:PieSeries>
</chart:SfCircularChart>
Methods
ClearSelection()
This method used is called to reset the SelectionBehavior, by clearing all SelectedIndex and SelectedIndexes value.
Declaration
public void ClearSelection()
Events
SelectionChanged
Occurs when the user clicks on series segment or sets the value for the SelectedIndex property. Here you can get the corresponding series, current selected index, and previous selected index.
Declaration
public event EventHandler<ChartSelectionChangedEventArgs> SelectionChanged
Event Type
Type |
---|
System.EventHandler<ChartSelectionChangedEventArgs> |
SelectionChanging
Occurs when the user clicks on the series segment or sets the value for SelectedIndex property. This event is triggered before a segment or series is selected.
Declaration
public event EventHandler<ChartSelectionChangingEventArgs> SelectionChanging
Event Type
Type |
---|
System.EventHandler<ChartSelectionChangingEventArgs> |
Remarks
Restrict a data point from being selected, by canceling this event, by setting Cancel property to true in the event argument.