menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ChartSelectionBehavior - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ChartSelectionBehavior

    The ChartSelectionBehavior is the base class for DataPointSelectionBehavior, and SeriesSelectionBehavior.

    Inheritance
    System.Object
    ChartBehavior
    ChartSelectionBehavior
    DataPointSelectionBehavior
    SeriesSelectionBehavior
    Inherited Members
    ChartBehavior.OnTouchDown(ChartBase, Single, Single)
    ChartBehavior.OnTouchMove(ChartBase, Single, Single)
    ChartBehavior.OnTouchUp(ChartBase, Single, Single)
    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
    • MainPage.xaml
    • MainPage.xaml.cs
    <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>
     SfCircularChart chart = new SfCircularChart();
     ViewModel viewModel = new ViewModel();
    
     PieSeries series = new PieSeries()
     {
        ItemsSource = viewModel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue",
     };
    
     series.SelectionBehavior = new DataPointSelectionBehavior()
     {
         SelectedIndex = 3,
         SelectionBrush = new SolidColorBrush(Colors.Red),
     };
    
     chart.Series.Add(series);

    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

    This property value is used only when Type is set to Multiple.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <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>
     SfCircularChart chart = new SfCircularChart();
     ViewModel viewModel = new ViewModel();
    
     PieSeries series = new PieSeries()
     {
        ItemsSource = viewModel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue",
     };
    
     List<int> indexes = new List<int>() { 1, 3, 5 };
     series.SelectionBehavior = new DataPointSelectionBehavior()
     {
         Type = ChartSelectionType.Multiple,
         SelectedIndexes= indexes,
         SelectionBrush = new SolidColorBrush(Colors.Red),
     };
    
     chart.Series.Add(series);

    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
    • MainPage.xaml
    • MainPage.xaml.cs
    <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>
     SfCircularChart chart = new SfCircularChart();
     ViewModel viewModel = new ViewModel();
    
     PieSeries series = new PieSeries()
     {
        ItemsSource = viewModel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue",
     };
    
     series.SelectionBehavior = new DataPointSelectionBehavior()
     {
         SelectionBrush = new SolidColorBrush(Colors.Red),
     };
    
     chart.Series.Add(series);

    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
    • MainPage.xaml
    • MainPage.xaml.cs
    <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>
     SfCircularChart chart = new SfCircularChart();
     ViewModel viewModel = new ViewModel();
    
     PieSeries series = new PieSeries()
     {
        ItemsSource = viewModel.Data,
        XBindingPath = "XValue",
        YBindingPath = "YValue",
     };
    
     series.SelectionBehavior = new DataPointSelectionBehavior()
     {
         Type = ChartSelectionType.Multiple,
         SelectionBrush = new SolidColorBrush(Colors.Red),
     };
    
     chart.Series.Add(series);

    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.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved