Version

Selection

This topic provides information for enabling and using the selection feature in the XamDataPieChart control.

The topic contains the following sections:

Requirements

This article assumes you have already read the Data Binding topic, and uses the code within it as a starting point.

Selection Overview

The XamDataPieChart supports slice selection by mouse click on the slices plotted in the chart. The different facets of the selection feature in the chart are described below:

Selection Behaviors

The main two options of the SelectionBehavior are PerDataItemSingleSelect and PerDataItemMultiSelect, which will enable single and multiple selection, respectively.

Selection Modes

The SelectionMode property determines how the pie chart slices respond to being selected. This property is defined by the SeriesSelectionMode enumeration. The following are the options of that enumeration and what they do:

  • Brighten: The selected slices will be highlighted.

  • FadeOthers: The selected slices will remain their same color and others will fade.

  • FocusColorFill: The selected slices will change their background to the FocusBrush of the XamDataPieChart control.

  • FocusColorOutline: The selected slices will have an outline with the color defined by the FocusBrush of the XamDataPieChart control.

  • FocusColorThickOutline: The selected slices will have an outline with the color defined by the FocusBrush of the XamDataPieChart control. The thickness of this outline can be configured via the Thickness property of the control as well.

  • GrayscaleOthers: The unselected slices will have a gray color filter applied to them.

  • None: There is no effect on the selected slices.

  • SelectionColorFill: The selected slices will change their background to the SelectionBrush of the XamDataPieChart control.

  • SelectionColorOutline: The selected slices will have an outline with the color defined by the SelectionBrush of the XamDataPieChart control.

  • SelectionColorThickOutline: The selected slices will have an outline with the color defined by the FocusBrush of the XamDataPieChart control. The thickness of this outline can be configured via the Thickness property of the control as well.

  • ThickOutline: The selected slices will apply an outline with the thickness dependent on the Thickness property of the XamDataPieChart control.

Selection Events

When a slice is selected, it’s underlying data item will be added to the SelectedSeriesItems collection of the chart. As such, the XamDataPieChart exposes the SelectedSeriesItemsChanged event to detect when a slice has been selected and this collection is changed.

Code Example

In XAML:

<ig:XamDataPieChart ItemsSource="{Binding Data}"
                    SelectionBehavior="PerDataItemMultiSelect"
                    SelectionMode="SelectionColorFill"
                    SelectionBrush="DodgerBlue" />

In C#:

XamDataPieChart dataPieChart = new XamDataPieChart()
{
    ItemsSource = data,
    SelectionBehavior = SeriesSelectionBehavior.PerDataItemMultiSelect,
    SelectionMode = SeriesSelectionMode.SelectionColorFill,
    SelectionBrush = Brushes.DodgerBlue
};

Related Content