private void OnSeriesChanged(IPieSeries oldValue, IPieSeries newValue) { if (_isLoaded) { UnsubscribeFrom(oldValue); SubscribeTo(newValue); } }
private void UnsubscribeFrom(IPieSeries series) { var notifiable = series as INotifyPropertyChanged; if (notifiable != null) { notifiable.PropertyChanged -= SeriesOnPropertyChanged; } if (series != null) { UnsubscribeFrom(series.Slices); } ClearItems(); }
private void SubscribeTo(IPieSeries series) { var notifiable = series as INotifyPropertyChanged; if (notifiable != null) { notifiable.PropertyChanged += SeriesOnPropertyChanged; } if (series != null) { SubscribeTo(series.Slices); AddItems(series.Slices); _slices = series.Slices; } else { _slices = null; } SumOfSlices = _slices != null ? _slices.Sum(x => x.Value) : 0; }