title: Create a full size WPF grid
body: <p>I am trying to fit a wpf grid having 4 cells to be all the time full sized on the screen, having the content of the cells equally split, but i am having problems doing it... This is the code:</p>
  
  <pre><code>    &lt;StackPanel x:Name="MainStackPanel" HorizontalAlignment="Center"  Orientation="Vertical"&gt;
      &lt;StackPanel.Resources&gt;
          &lt;Style TargetType="Rectangle"&gt;
              &lt;Setter Property="HorizontalAlignment" Value="Stretch"/&gt;
              &lt;Setter Property="Height" Value="Auto"/&gt;
          &lt;/Style&gt;
      &lt;/StackPanel.Resources&gt;
      &lt;Grid x:Name="Control1" HorizontalAlignment="Center" Height="150"&gt;
          &lt;Grid.Resources&gt;
              &lt;Style TargetType="Rectangle"&gt;
                  &lt;Setter Property="HorizontalAlignment" Value="Stretch"/&gt;
                  &lt;Setter Property="Height" Value="Auto"/&gt;
              &lt;/Style&gt;
          &lt;/Grid.Resources&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition/&gt;
              &lt;ColumnDefinition/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;Rectangle Fill="Red" Grid.Row="0" Grid.Column="1"/&gt;
          &lt;Rectangle Fill="Blue" Grid.Row="0" Grid.Column="2"/&gt;
          &lt;Rectangle Fill="Green" Grid.Row="1" Grid.Column="2"/&gt;
          &lt;Rectangle Fill="Yellow" Grid.Row="1" Grid.Column="1"/&gt;
      &lt;/Grid&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Please let me know how should i get this working... or what i am doing wrong...</p>