title: DataContext binding to a rectangle
body: <p>I have a class Student with 3 attributes (first name, last name, age).</p>
  
  <p>In .xaml ( basically two rectangles - each containing 3 text blocks bind to those 3 attributes).</p>
  
  <pre><code>&lt;Border  Grid.Column="0" Grid.Row="5" &gt;
          &lt;StackPanel Orientation="Horizontal"&gt;
                  &lt;Rectangle Width="16" Height="16" Name="rectangle1" /&gt;
                  &lt;TextBlock Text="{Binding Mode=TwoWay, Path=FirstName}"  Padding="2"/&gt;
                  &lt;TextBlock Text="{Binding Mode=TwoWay, Path=LastName}" Padding="2"/&gt;
                  &lt;TextBlock Text="{Binding Mode=TwoWay, Path=Age}" Padding="2"/&gt;
          &lt;/StackPanel&gt;
      &lt;/Border&gt;
      &lt;Border  Grid.Column="0" Grid.Row="6"&gt;
          &lt;StackPanel Orientation="Horizontal"&gt;
              &lt;Rectangle Width="16" Height="16"  Fill="{Binding Converter={StaticResource AvailabilityToBrushConverter1}, Path=IsAvailable}" Name="rectangle2"/&gt;
              &lt;TextBlock Text="{Binding Mode=TwoWay, Path=FirstName}"  Padding="2"/&gt;
              &lt;TextBlock Text="{Binding Mode=TwoWay, Path=LastName}" Padding="2"/&gt;
              &lt;TextBlock Text="{Binding Mode=TwoWay, Path=Age}" Padding="2"/&gt;
          &lt;/StackPanel&gt;
      &lt;/Border&gt;
  </code></pre>
  
  <p>In .xaml.cs</p>
  
  <pre><code>Student student1 = new Student { FirstName = "James", LastName = "Peter", Age= 12 ,IsAvailable=true  };
  Student student2 = new Student { FirstName = "Mark", LastName = "Smith", Age = 20 };
  </code></pre>
  
  <p>after InitializeComponent</p>
  
  <pre><code>InitializeComponent();     
  DataContext = student1;
  </code></pre>
  
  <p>When i run i get </p>
  
  <blockquote>
    <p>James Peter 12<br> James Peter 12</p>
  </blockquote>
  
  <p>I want on form load</p>
  
  <blockquote>
    <p>James Peter 12<br> Mark  Smith 20</p>
  </blockquote>
  
  <p>I tried to use this, but didn't work:</p>
  
  <pre><code>rectangle1.DataContext=student1;
  rectangle2.DataContext=student2;
  </code></pre>
  
  <p>How do i set two different values for these 2 rectangles? </p>