Beispiel #1
0
        private static void OnSelectionStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChartSelectionBehavior behavior = d as ChartSelectionBehavior;

            SfChart chartBase = behavior.ChartArea;

            // WPF-26121, When selection style is changed the last selected segment remains selected
            if (chartBase == null || chartBase.Series == null)
            {
                return;
            }

            chartBase.SeriesSelectedIndex = -1;

            foreach (ChartSeries series in chartBase.Series)
            {
                var segmentSelectableSeries = series as ISegmentSelectable;
                if (segmentSelectableSeries != null)
                {
                    segmentSelectableSeries.SelectedIndex = -1;
                }

                if (chartBase.SelectedSeriesCollection.Contains(series) &&
                    chartBase.SeriesSelectedIndex != chartBase.Series.IndexOf(series))
                {
                    chartBase.SelectedSeriesCollection.Remove(series);
                    chartBase.OnResetSeries(series);
                }

                // Need to revisit the code.
                for (int i = 0; i < series.ActualData.Count; i++)
                {
                    if (series.SelectedSegmentsIndexes.Contains(i))
                    {
                        series.SelectedSegmentsIndexes.Remove(i);
                        series.OnResetSegment(i);
                    }
                }
            }
        }
Beispiel #2
0
        private static void OnEnableSeriesSelectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SfChart chartBase = (d as ChartSelectionBehavior).ChartArea;

            if (chartBase != null && !(bool)e.NewValue)
            {
                foreach (ChartSeries series in chartBase.Series)
                {
                    if (chartBase.SelectedSeriesCollection.Contains(series))
                    {
                        chartBase.SelectedSeriesCollection.Remove(series);
                        chartBase.OnResetSeries(series);
                    }
                }

                chartBase.SeriesSelectedIndex = -1;
                chartBase.SelectedSeriesCollection.Clear();
            }
            else if (chartBase != null && (bool)e.NewValue && chartBase.SeriesSelectedIndex != -1)
            {
                chartBase.SeriesSelectedIndexChanged(chartBase.SeriesSelectedIndex, -1);
            }
        }