Class ChartSelectionBehavior

    Show / Hide Table of Contents

    Class ChartSelectionBehavior

    Inheritance
    System.Object
    ChartBehavior
    ChartSelectionBehavior
    DataPointSelectionBehavior
    SeriesSelectionBehavior
    Inherited Members
    ChartBehavior.OnDoubleTapped(DoubleTappedRoutedEventArgs)
    ChartBehavior.OnHolding(HoldingRoutedEventArgs)
    ChartBehavior.OnManipulationCompleted(ManipulationCompletedRoutedEventArgs)
    ChartBehavior.OnManipulationDelta(ManipulationDeltaRoutedEventArgs)
    ChartBehavior.OnManipulationStarted(ManipulationStartedRoutedEventArgs)
    ChartBehavior.OnPointerEntered(PointerRoutedEventArgs)
    ChartBehavior.OnPointerExited(PointerRoutedEventArgs)
    ChartBehavior.OnPointerMoved(PointerRoutedEventArgs)
    ChartBehavior.OnPointerWheelChanged(PointerRoutedEventArgs)
    ChartBehavior.OnRightTapped(RightTappedRoutedEventArgs)
    ChartBehavior.OnTapped(TappedRoutedEventArgs)
    Namespace: Syncfusion.UI.Xaml.Charts
    Assembly: Syncfusion.Chart.WinUI.dll
    Syntax
    public abstract class ChartSelectionBehavior : ChartBehavior

    Constructors

    ChartSelectionBehavior()

    Initializes a new instance of the ChartSelectionBehavior class.

    Declaration
    public ChartSelectionBehavior()

    Fields

    SelectedIndexesProperty

    The DependencyProperty for SelectedIndexes property.

    Declaration
    public static readonly DependencyProperty SelectedIndexesProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    SelectedIndexProperty

    The DependencyProperty for SelectedIndex property.

    Declaration
    public static readonly DependencyProperty SelectedIndexProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    SelectionBrushProperty

    The DependencyProperty for SelectionBrush property.

    Declaration
    public static readonly DependencyProperty SelectionBrushProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    TypeProperty

    The DependencyProperty for Type property.

    Declaration
    public static readonly DependencyProperty TypeProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    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>
    
            <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>
    
            <chart:PieSeries ItemsSource="{Binding Data}"
                             XBindingPath="XValue"
                             YBindingPath="YValue">
                <chart:PieSeries.SelectionBehavior>
                    <chart:DataPointSelectionBehavior 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()
     {
         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.UI.Xaml.Media.Brush

    This property takes Microsoft.UI.Xaml.Media.Brush value and its default value is null.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCircularChart>
    
            <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

    One of the ChartSelectionType. The default is Single selection.

    Remarks

    It's used to select single or multiple segments or series.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCircularChart>
    
            <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

    OnPointerPressed(PointerRoutedEventArgs)

    Declaration
    protected override void OnPointerPressed(PointerRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e
    Overrides
    ChartBehavior.OnPointerPressed(PointerRoutedEventArgs)

    OnPointerReleased(PointerRoutedEventArgs)

    Declaration
    protected override void OnPointerReleased(PointerRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e
    Overrides
    ChartBehavior.OnPointerReleased(PointerRoutedEventArgs)

    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 Description
    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 Description
    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 - 2023 Syncfusion Inc. All Rights Reserved