title: Binding List of data to several DataGrid
body: <p>I have data in ViewModel which I bind to DataGrid. But I need multiple data and bind that dynamically to several DataGrids.</p>
  
  <pre><code>public sealed class ViewModel : INotifyPropertyChanged
  {
      private DataTable data;
      public DataTable Data
      {
          get { return data; }
          set { data = value; OnPropertyChanged("Data"); }
      }
  
      private char[] head;
      public char[] Head
      {
          get { return head; }
          set { head = value; OnPropertyChanged("Head"); }
      }
  
      private char name;
      public char Name
      {
          get { return name; }
          set { name = value; OnPropertyChanged("Name"); }
      }
      private static readonly ViewModel instance = new ViewModel();
  
      public static ViewModel Instance
      {
          get { return instance; }
      } 
      private ViewModel()
      {
          data = new DataTable();
      }
  
      protected void OnPropertyChanged(string propertyName)
      {
          if (null != PropertyChanged)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
  }
  </code></pre>
  
  <p>My DataGrid in XAML</p>
  
  <pre><code>&lt;DataGrid Name="dtgOutput" Grid.Row="0" Grid.Column="2" AutoGenerateColumns="True" IsReadOnly="True" Width="Auto" Height="Auto" VerticalAlignment="Top"
                    ItemsSource="{Binding Data, diag:PresentationTraceSources.TraceLevel=High}" HeadersVisibility="All"&gt;
    &lt;DataGrid.RowHeaderTemplate&gt;
      &lt;DataTemplate&gt;
        &lt;TextBlock Text="Row header" /&gt;
      &lt;/DataTemplate&gt;
    &lt;/DataGrid.RowHeaderTemplate&gt;
    &lt;DataGrid.Resources&gt;
      &lt;Style TargetType="Button" x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}"&gt;
        &lt;Setter Property="Content" Value="{Binding Name}" /&gt;
      &lt;/Style&gt;
    &lt;/DataGrid.Resources&gt;
  &lt;/DataGrid&gt; 
  </code></pre>
  
  <p>I have an idea like this: to have any collection and each item to bind to one DataGrid. I don't know how much items will be in the collection, of course.</p>
  
  <pre><code>List&lt;Data&gt; list = new List&lt;Data&gt;;
  list.Add(new Data(dataTable, head, name);
  list.Add(new Data(dataTable, head, name);
  
  list[0]; //bind to first DataGrid
  list[1]; //bind to second DataGrid
  </code></pre>
  
  <p>Any idea?</p>