title: how to bind a datagrid to a custom class object
body: <p>i want to bind a datagrid with a observablecollection of a custom class </p>
  
  <p>lets say i have a class A and class B</p>
  
  <pre><code>  Class A
    {
         public B b {get;set;}
         public bool boo {get;set;}
    }
  </code></pre>
  
  <p>and DataGrid as </p>
  
  <pre><code>   &lt;DataGrid x:Name="Dg" ItemsSource="{Binding}" AutoGenerateColumns="False"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridCheckBoxColumn x:Name="DgCheckBoxColumn" Visibility="Collapsed" Width="30" Binding="{Binding Path=boo, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" IsReadOnly="False"/&gt;
                  &lt;DataGridTextColumn Header="Id" Binding="{Binding Id}" IsReadOnly="True"/&gt;
                  &lt;DataGridTextColumn Header="Title" Binding="{Binding Title}" IsReadOnly="True"/&gt;
                  &lt;DataGridTextColumn Header="Type" Binding="{Binding  Type}" IsReadOnly="True"/&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>other values like Id and title are available in class B</p>
  
  <p>Code Behind</p>
  
  <pre><code>  ObservableCollection&lt;A&gt; a=new ObservableCollection&lt;A&gt;();
    DgContent.DataContext = a;
  </code></pre>
  
  <p>but it shows empty</p>
  
  <p>if the change the datagrid binding to </p>
  
  <pre><code>          Binding="{Binding path=b.Id }"
  </code></pre>
  
  <p>it shows data but also in some other place i bind the same grid to the ObservableCollection of class B and it shows data , so i want to switch between the datacontext for the two objects and show data</p>
  
  <p>is it possible to do it with the same DataGrid?</p>