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:
<StackPanel x:Name="MainStackPanel" HorizontalAlignment="Center" Orientation="Vertical">
<StackPanel.Resources>
<Style TargetType="Rectangle">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Height" Value="Auto"/>
</Style>
</StackPanel.Resources>
<Grid x:Name="Control1" HorizontalAlignment="Center" Height="150">
<Grid.Resources>
<Style TargetType="Rectangle">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Height" Value="Auto"/>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Rectangle Fill="Red" Grid.Row="0" Grid.Column="1"/>
<Rectangle Fill="Blue" Grid.Row="0" Grid.Column="2"/>
<Rectangle Fill="Green" Grid.Row="1" Grid.Column="2"/>
<Rectangle Fill="Yellow" Grid.Row="1" Grid.Column="1"/>
</Grid>
</StackPanel>
Please let me know how should i get this working... or what i am doing wrong...