When trying to add source to my DataGrid im getting error Object reference not set to an instance of an object. I dont really understand the problem, how can I solve it?


    public partial class PageAttributeData : Window
    {
        public PageAttributeData()
        {

                DataAttributeCollection dac = new DataAttributeCollection();
                DataAttribute da = new DataAttribute("Wind");
                da.AddValue("Weak");
                da.AddValue("Strong");
                da.AddValue("Medium");
                dac.Add(da);
                da = new DataAttribute("Temperature");
                da.AddValue("Low");
                da.AddValue("Medium");
                da.AddValue("High");
                dac.Add(da);
            AttributeDataGrid.ItemsSource = dac;

            InitializeComponent();

        }
    }

I think its not about any null in list but about DataGrid, maybe i've just wrote something wrong?

0 Answers