Why is observablecollection initialized to null?
<p>I used this constructor to initialize this object</p>

<pre><code> ObservableCollection&lt;MyHomeworkModel&gt; allTabs = new ObservableCollection&lt;MyHomeworkModel&gt;();
</code></pre>

<p>It turned out that allTabs was null after initialization. I couldn't add MyHomeworkModel objects to it because of that.</p>

<p>Please help me and thanks in advance.</p>

<pre><code>using System.Windows.Input;
using System.Collections.ObjectModel;
using MyHomework;

namespace MyHomework__MVVM_
{
    class MyHomeworkViewModel
    {
        private ObservableCollection&lt;MyHomeworkModel&gt; allTabs;
        private MyHomeworkModel selectedTab;

        public MyHomeworkViewModel()
        {
            ObservableCollection&lt;MyHomeworkModel&gt; allTabs = new ObservableCollection&lt;MyHomeworkModel&gt;();
            selectedTab = new MyHomeworkModel();
            AddCourseCommand = new AddCourseCommand(this);
        }

        public ObservableCollection&lt;MyHomeworkModel&gt; AllTabs
        {
            get
            {
                return allTabs;
            }
            set
            {
                allTabs = value;
            }
        }

        public MyHomeworkModel SelectedTab
        {
            get
            {
                return selectedTab;
            }
            set
            {
                selectedTab = value;
            }
        }

        public ICommand AddCourseCommand
        {
            get;
            private set;
        }

        public void AddNewTab()
        {
            NewCourseName ncn = new NewCourseName();
            ncn.ShowDialog();
            if (ncn.courseName != null)
            {
                MyHomeworkModel newTab = new MyHomeworkModel();
                newTab.Header = ncn.courseName;
                AllTabs.Add(newTab);
            }
        }
    }
}
</code></pre>
