Please have a look at my code below:
<Border Background="#242328" CornerRadius="10" Opacity="0.9">
<Grid Width="400">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="80"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding [someViewModel].Title}" Margin="0,20,0,20"/>
<StackPanel Grid.Row="1" Orientation="Vertical">
<TextBlock Margin="20,0,0,0" Text="{Binding [someViewModel].AnotherText}"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Vertical">
<Image Source="{Binding [someViewModel].source}" Width="100" Height="100"/>
<TextBlock Margin="20,0,0,0" Text="{Binding [someViewModel].AnotherText2}"/>
</StackPanel>
<Grid Grid.Row="3" Width="250" Margin="0,10,10,10">
<Button Width="120" Height="50" Background="#638699" Content="OK" FontSize="18"/>
</Grid>
</Grid>
</Border>
Output of the code above:
Now my question very simple, why there is empty space above the button? I've already set all RowDefinition Height="Auto"
, when there isn't any value in my variable, shouldn't the box shrink to left only button?
Please note that all the variable such as [someViewModel].Title, [someViewModel].AnotherText, [someViewModel].AnotherText2, [someViewModel].Source will be null