alexa
Syncfusion
menu Syncfusion

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ChartSelectionBehavior

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

    Inheritance
    object
    ChartBehavior
    ChartSelectionBehavior
    DataPointSelectionBehavior
    SeriesSelectionBehavior
    Inherited Members
    ChartBehavior.OnTouchDown(ChartBase, float, float)
    ChartBehavior.OnTouchMove(ChartBase, float, float)
    ChartBehavior.OnTouchUp(ChartBase, float, float)
    Namespace: Syncfusion.Maui.Charts
    Assembly: Syncfusion.Maui.Charts.dll
    Syntax
    public abstract class ChartSelectionBehavior : ChartBehavior

    Constructors

    ChartSelectionBehavior()

    Initializes a new instance of the ChartSelectionBehavior class.

    Declaration
    public ChartSelectionBehavior()

    Fields

    SelectedIndexProperty

    Identifies the SelectedIndex bindable property.

    Declaration
    public static readonly BindableProperty SelectedIndexProperty
    Field Value
    Type
    BindableProperty

    SelectedIndexesProperty

    Identifies the SelectedIndexes bindable property.

    Declaration
    public static readonly BindableProperty SelectedIndexesProperty
    Field Value
    Type
    BindableProperty

    SelectionBrushProperty

    Identifies the SelectionBrush bindable property.

    Declaration
    public static readonly BindableProperty SelectionBrushProperty
    Field Value
    Type
    BindableProperty

    TypeProperty

    Identifies the Type bindable property.

    Declaration
    public static readonly BindableProperty TypeProperty
    Field Value
    Type
    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
    int

    This property takes int 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
    List<int>

    This property takes the list of int 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
    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
    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
    EventHandler<ChartSelectionChangingEventArgs>
    Remarks

    Restrict a data point from being selected, by canceling this event, by setting Cancel property to true in the event argument.

    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved