What is the best way to add back image with TapRecognizer in top left corner? I have only one condition and that is that back button must be aligned with logo which is on center of the page. I started with RelativeLayout which is a part of StackLayout.
Only thing is that my HeightRequest of the logo is Binding property to code behind, and therefore I cant know size on a different screens (Binding property takes App.Height and divide with some number, to be proportional on all phones the same).
XAML:
<ContentPage.Content>
<ScrollView>
<StackLayout
Padding="{Binding MainStackSidePadding}"
Spacing="15">
<RelativeLayout
Padding="{Binding MainStackSidePadding}"
BackgroundColor="Red">
<Image x:Name="logo" Source="testbar.png" HorizontalOptions="Center" HeightRequest="{Binding LogoSmallHeight}"
RelativeLayout.XConstraint =
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.5,
Constant=0}"
RelativeLayout.YConstraint =
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0,
Constant=0}"/>
<Image x:Name="backButton" Source="back.png" HeightRequest="30"
RelativeLayout.XConstraint =
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0.025,
Constant=0}"
RelativeLayout.YConstraint =
"{ConstraintExpression Type=RelativeToView,
ElementName = logo,
Property=Height,
Factor=0,
Constant=50}">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding GoBackCommand}"/>
</Image.GestureRecognizers>
</Image>
</RelativeLayout>
<!--Some other elements and labels etc. -->
</StackLayout>
</ScrollView>
</ContentPage.Content>
Maybe the RelativeLayout isn't the best solution for this problem? Thanks.