Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

An Image inside a Grid makes it expand to fill full height.

$
0
0

Please consider the following XAML:

<?xml version="1.0" encoding="utf-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyNamespace.MainPage"> <ContentPage.Padding> <OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" /> </ContentPage.Padding> <Grid VerticalOptions="Start" BackgroundColor="Red"> <Grid.ColumnDefinitions> <ColumnDefinition Width="50*" /> <ColumnDefinition Width="50*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="150" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Label Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Text="Post #1" /> <!--Image Grid.Column="0" Grid.Row="1" Aspect="AspectFit" BackgroundColor="Lime" Source="http://www.w3schools.com/css/img_fjords.jpg" /--> <Label Grid.Column="0" Grid.Row="1" BackgroundColor="Silver" Text="1" /> <Label Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" BackgroundColor="Olive" Text="Post #1 text text text text text text text text text text text text text text xt text text text text text text text text text text text text text text text text text text text xt text text text text text text text" /> <Label Grid.Column="0" Grid.Row="2" BackgroundColor="Silver" Text="2" /> </Grid> </ContentPage>

If Label is displayed in col=0, row=1, it works perfect (see the first screen). But If you switch it to Image instead, Grid behaves strange, filling the whole page (see the second screen).


Viewing all articles
Browse latest Browse all 91519

Trending Articles