示例#1
0
        private void SetData()
        {
            _titles.Clear();
            _values.Clear();
            _userData.Clear();

            if (!string.IsNullOrEmpty(TitleMemberPath) && !string.IsNullOrEmpty(ValueMemberPath))
            {
                BindingEvaluator titleEval    = new BindingEvaluator(TitleMemberPath);
                BindingEvaluator valueEval    = new BindingEvaluator(ValueMemberPath);
                BindingEvaluator userDataEval = new BindingEvaluator(UserDataMemberPath);

                foreach (object dataItem in this.DataSource)
                {
                    _titles.Add(titleEval.Eval(dataItem).ToString());
                    _values.Add((double)valueEval.Eval(dataItem));
                    _userData.Add(userDataEval.Eval(dataItem));

                    if (dataItem is INotifyPropertyChanged)
                    {
                        (dataItem as INotifyPropertyChanged).PropertyChanged -= OnDataSourceItemPropertyChanged;
                        (dataItem as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler(OnDataSourceItemPropertyChanged);
                    }
                }

                _total = _values.Sum();
            }
        }
示例#2
0
 private void ProcessCategoryData()
 {
     _categoryValues.Clear();
     if (this.DataSource != null && !string.IsNullOrEmpty(CategoryValueMemberPath))
     {
         BindingEvaluator eval = new BindingEvaluator(CategoryValueMemberPath);
         foreach (object dataItem in this.DataSource)
         {
             _categoryValues.Add(eval.Eval(dataItem).ToString());
         }
     }
 }
 private void ProcessCategoryData()
 {
     _categoryValues.Clear();
     if (this.DataSource != null && !string.IsNullOrEmpty(CategoryValueMemberPath))
     {
         BindingEvaluator eval = new BindingEvaluator(CategoryValueMemberPath);
         foreach (object dataItem in this.DataSource)
         {
             _categoryValues.Add(eval.Eval(dataItem).ToString());
         }
     }
 }
        private void SetData()
        {
            _titles.Clear();
            _values.Clear();
            _userData.Clear();

            if (!string.IsNullOrEmpty(TitleMemberPath) && !string.IsNullOrEmpty(ValueMemberPath))
            {
                BindingEvaluator titleEval = new BindingEvaluator(TitleMemberPath);
                BindingEvaluator valueEval = new BindingEvaluator(ValueMemberPath);
                BindingEvaluator userDataEval = new BindingEvaluator(UserDataMemberPath);

                foreach (object dataItem in this.DataSource)
                {
                    _titles.Add(titleEval.Eval(dataItem).ToString());
                    _values.Add((double)valueEval.Eval(dataItem));
                    _userData.Add(userDataEval.Eval(dataItem));

                    if (dataItem is INotifyPropertyChanged)
                    {
                        (dataItem as INotifyPropertyChanged).PropertyChanged -= OnDataSourceItemPropertyChanged;
                        (dataItem as INotifyPropertyChanged).PropertyChanged += new PropertyChangedEventHandler(OnDataSourceItemPropertyChanged);
                    }
                }

                _total = _values.Sum();
            }
        }
        private void SetData()
        {
            _titles.Clear();
            _values.Clear();

            if (string.IsNullOrWhiteSpace(TitleMemberPath) || string.IsNullOrWhiteSpace(ValueMemberPath))
            {
                return;
            }

            var titleEvaluator = new BindingEvaluator(TitleMemberPath);
            var valueEvaluator = new BindingEvaluator(ValueMemberPath);
            foreach (var dataItem in DataSource)
            {
                _titles.Add(titleEvaluator.Eval(dataItem).ToString());
                _values.Add((double)valueEvaluator.Eval(dataItem));

                if (!(dataItem is INotifyPropertyChanged))
                {
                    continue;
                }

                (dataItem as INotifyPropertyChanged).PropertyChanged -= OnDataSourceItemPropertyChanged;
                (dataItem as INotifyPropertyChanged).PropertyChanged += OnDataSourceItemPropertyChanged;
            }
            _total = _values.Sum();
        }
        private void ProcessCategoryData()
        {
            _categoryValues.Clear();

            if (DataSource == null || string.IsNullOrEmpty(CategoryValueMemberPath))
            {
                return;
            }

            var evaluator = new BindingEvaluator(CategoryValueMemberPath);

            foreach (var val in from object dataItem in DataSource
                select string.IsNullOrEmpty(CategoryFormatString)
                    ? (evaluator.Eval(dataItem).ToString())
                    : string.Format(CategoryFormatString, evaluator.Eval(dataItem)))
                _categoryValues.Add(val);
        }