Binding Chart and DataGrid to same ObservableCollection

May 20, 2014 at 2:00 PM
I am trying to bind a DataGrid and a PieChart to the same ObservableCollection, however when I view the chart all it shows is a "0", the legend shows correctly (see image)

Image

The DataGrid shows correctly, when I remove the ItemSource binding from the DataGrid the graph will show properly. Any idea what is causing this? Below is the relevant code:
<DataGrid ItemsSource="{Binding Path=Errors}" AutoGenerateColumns="True">
<Chart:PieChart.Series>
         <Chart:ChartSeries 
                   SeriesTitle="Populations"
                   DisplayMember="Category"
                   ValueMember="Number"
                   ItemsSource="{Binding Path=Errors}"/>
          </Chart:PieChart.Series>
public class MainViewModel
    {
        
        public MainViewModel()
        {
            Errors = new ObservableCollection<TestClass>();

            Errors.Add(new TestClass() { Category = "Globalization", Number = 75 });
            Errors.Add(new TestClass() { Category = "Features", Number = 2 });
            Errors.Add(new TestClass() { Category = "ContentTypes", Number = 12 });
            Errors.Add(new TestClass() { Category = "Correctness", Number = 83 });
        }

        public ObservableCollection<TestClass> Errors
        {
            get;
            set;
        }
    }

    public class TestClass : INotifyPropertyChanged
    {
        private string _category = "";
        public string Category
        {
            get
            {
                return _category;
            }
            set
            {
                _category = value;
                if (PropertyChanged != null)
                {
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Category"));
                }
            }
        }

        private double _number = 0;
        public double Number
        {
            get
            {
                return _number;
            }
            set
            {
                _number = value;
                if (PropertyChanged != null)
                {
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Number"));
                }
            }

        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
My goal is that I want to be able to edit data in the DataGrid and that these changes will alter the graph.