Reputation: 870
I am very new to Xamarin for mobile. How can I make a box with percentage dimensions such that it contains a square picture on its left, text on its right, and the entire entity is subject to touch like a button? Even better, with the children on the right side to be vertically stacked. The specific configuration as asked is entirely arbitrary, simply a reference example.
Upvotes: 1
Views: 93
Reputation: 74184
There are many ways this could be done, here is one via a Grid
that I added a TapGestureRecognizer
to it:
<Grid BackgroundColor="Gray">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="Handle_Tapped" />
</Grid.GestureRecognizers>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="deli.jpg" Margin="5,5,5,5" Aspect="AspectFill" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" />
<StackLayout BackgroundColor="Black" Orientation="Vertical" Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" VerticalOptions="CenterAndExpand">
<Label Text="Cured" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
<Label Text="Meat" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
<Label Text="(View More)" TextColor="White" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" />
</StackLayout>
</Grid>
Upvotes: 1