title: DataGrid - Binding to a list of lists with MVVM
body: <p>I have a 'Person' class that can have a list of Items.</p>
  
  <p><strong>Person.cs</strong></p>
  
  <pre><code>public class Person : ObservableObject
  {
    private string _id;
    public string Id
    {
      get { return _id; }
      set
      {
        _id = value;
        RaisePropertyChangedEvent("Id");
      }
    }
  
    ...
  
    Private IList&lt;Item&gt; _items;
    public IList&lt;Item&gt; Items
    {
      get { return _items; }
      set
      {
        _items = value;
        RaisePropertyChangedEvent("Items");
      }
    }
  }
  </code></pre>
  
  <p><strong>Item.cs</strong></p>
  
  <pre><code>public class Item : ObservableObject
  {
    private string _id;
    public string Id
    {
      get { return _id; }
      set
      {
        _id = value;
        RaisePropertyChangedEvent("Id");
      }
    } 
  
    ...
  }
  </code></pre>
  
  <p>I am trying to display this in a tabbed data grid. First Tab is "Person" and the second tab is "Items".</p>
  
  <p><strong>.XAML</strong></p>
  
  <pre><code>    &lt;Window.DataContext&gt;
        &lt;viewModels:PersonViewModel /&gt;
      &lt;/Window.DataContext&gt;
  
      &lt;TabControl&gt;
          &lt;TabItem Header="Person"&gt;
              &lt;DataGrid ItemsSource="{Binding Person}" Width="1700" Height="800" AutoGenerateColumns="False" CanUserAddRows="false"
                        VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" RowHeight="20"&gt;
                  &lt;DataGrid.Columns&gt;
                      &lt;DataGridTextColumn Header="Id" Binding="{Binding Id}" IsReadOnly="True"/&gt;
                      ...
                  &lt;/DataGrid.Columns&gt;
              &lt;/DataGrid&gt;
           &lt;/TabItem&gt;
  
          &lt;TabItem Header="Items"&gt;
              &lt;DataGrid ItemsSource="{Binding Person.Items}" Width="1700" Height="800" AutoGenerateColumns="False" CanUserAddRows="false"
                        VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" RowHeight="20"&gt;
                  &lt;DataGrid.Columns&gt;
                      &lt;DataGridTextColumn Header="Person Id" Binding="{Binding Person.Id}" IsReadOnly="True"/&gt;
                      &lt;DataGridTextColumn Header="Id" Binding="{Binding Id}" IsReadOnly="True"/&gt;
                      ...
                  &lt;/DataGrid.Columns&gt;
              &lt;/DataGrid&gt;
          &lt;/TabItem&gt;
      &lt;/TabControl&gt;
  </code></pre>
  
  <p><strong>View Model.cs</strong></p>
  
  <pre><code>    private ObservableCollection&lt;Person&gt; _persons = new ObservableCollection&lt;Person&gt;();
  
  public ObservableCollection&lt;Person&gt; Person
  {
    get { return _persons; }
    set
    {
      _persons = value;
      RaisePropertyChangedEvent("Person");
    }
  }
  </code></pre>
  
  <p>This is as far as I have gotten. I'm assuming I need to somehow loop through the Person objects and then do Person.Items but am not sure.</p>
  
  <p>I am able to display my "Person" object perfectly fine, it is just the "Items" tab I am having issues with. I get the error <em>"cannot resolve property "Items" in datacontext of type ObservableCollection"</em></p>
  
  <p>Thank you for any help</p>