title: ObservableCollection not updating View
body: <p>I am just starting with MVVM and have hit a hurdle that I hope someone can help me with. I am trying to create a simple View with 2 listboxes. A selection from the first listbox will populate the second list box. I have a class created that stores the information I want to bind to.</p>
  
  <p>MyObject Class (Observable Object is just a base class that implements INotifyPopertyChanged)</p>
  
  <pre><code>public class MyObject : ObservableObject
  {
      String _name = String.Empty;
      ObservableCollection&lt;MyObject&gt; _subcategories;
  
      public ObservableCollection&lt;MyObject&gt; SubCategories
      {
          get { return _subcategories; }
  
          set
          {
              _subcategories = value;
              RaisePropertyChanged("SubCategories");
          }
      }
  
      public String Name
      {
          get { return _name; }
          set
          {
              _name = value;
              RaisePropertyChanged("Name");
          }
      }
  
  
      public MyObject()
      {
          _subcategories = new ObservableCollection&lt;EMSMenuItem&gt;();
      }
  }
  </code></pre>
  
  <p>In my viewmodel I have two ObservableCollections created</p>
  
  <pre><code>public ObservableCollection&lt;EMSMenuItem&gt; Level1MenuItems { get; set; }
  public ObservableCollection&lt;EMSMenuItem&gt; Level2MenuItems { get; set; }
  </code></pre>
  
  <p>In my constructor of the ViewModel I have:</p>
  
  <pre><code>this.Level1MenuItems = new ObservableCollection&lt;EMSMenuItem&gt;();
  this.Level2MenuItems = new ObservableCollection&lt;EMSMenuItem&gt;();
  this.Level1MenuItems = LoadEMSMenuItems("Sample.Xml");
  </code></pre>
  
  <p>That works fine for the Level1 items and they correctly show in the View. However I have a command that gets called when the user clicks an item in the listbox, which has the following:</p>
  
  <pre><code>Level2MenuItems = ClickedItem.SubCategories;
  </code></pre>
  
  <p>For some reason this does not update the UI of the second listbox. If I put a breakpoint at this location I can see that Level2MenuItems has the correct information stored in it. If I write a foreach loop and add them individually to the Level2MenuItems collection then it does display correctly.</p>
  
  <p>Also as a test I added the following to the constructor:</p>
  
  <pre><code>Level2MenuItems = Level1MenuItems[0].SubCategories;
  </code></pre>
  
  <p>And that updated correctly.</p>
  
  <p>So why would the code work as expected in the constructor, or when looping through, but not when a user clicks on an item in the listbox?</p>