Margin not working with ScrollView

Jassim Al Rahma 26 Reputation points
2023-06-08T16:04:26.6933333+00:00

I have the following XAML:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:System="clr-namespace:System;assembly=System.Runtime"
    xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
    ios:Page.UseSafeArea="False"
    xmlns:local="clr-namespace:MyApp"
    Shell.NavBarIsVisible="False"
    Shell.PresentationMode="ModalAnimated"
    x:Class="MyApp.Mobile.PrivacyPolicy">
    <Grid RowDefinitions="Auto,*,Auto">
        <Grid Grid.Row="0" ColumnDefinitions="Auto,*" ColumnSpacing="0" RowSpacing="0">
            <Border Grid.Column="0" Margin="10" Padding="0" BackgroundColor="#FF599B" WidthRequest="40" HeightRequest="40" HorizontalOptions="Start" VerticalOptions="Center">
            <Border.StrokeShape>
                <RoundRectangle CornerRadius="10" StrokeThickness="0" />
            </Border.StrokeShape>
                <Image Aspect="AspectFill" HorizontalOptions="Center" VerticalOptions="Center">
                <Image.Source>
                    <FontImageSource FontFamily="FontSolid" Glyph="{x:Static local:IconFont.IconBack}" Color="#FFFFFF" />
                </Image.Source>
                </Image>
            <Border.GestureRecognizers>
                <TapGestureRecognizer Tapped="CloseTapGestureRecognizer_Tapped" NumberOfTapsRequired="1" />
            </Border.GestureRecognizers>
            </Border>

            <Label Grid.Column="1" HorizontalOptions="Center" VerticalOptions="Center">
                <Label.FormattedText>
                    <FormattedString>
                        <Span FontSize="Header" FontFamily="PoppinsBold" Text="Privacy " TextColor="Black"/>
                        <Span FontSize="Header" FontFamily="PoppinsBold" Text="Policy" TextColor="#FF599B"/>
                    </FormattedString>
                </Label.FormattedText>
            </Label>
        </Grid>

        <ScrollView Grid.Row="1" VerticalScrollBarVisibility="Never">
            <VerticalStackLayout Margin="20,20,20,120">
                <Label>
                    <Label.FormattedText>
                        <FormattedString>
                            <Span Text="1. " />
                            <Span Text="{x:Static System:Environment.NewLine}" />
                            <Span Text="{x:Static System:Environment.NewLine}" />
                            <Span Text="2. " />
                        </FormattedString>
                    </Label.FormattedText>
                </Label>
            </VerticalStackLayout>
        </ScrollView>

        <Button x:Name="ButtonHelp" Grid.Row="2" Text="Contact us" HeightRequest="60" BackgroundColor="#FF599B" Margin="10,10,10,20" Clicked="ButtonHelp_Clicked" />
    </Grid>
</ContentPage>

But the Button hiding behind the ScrollView and no matter how much I set the Bottom Margin o f the ScrollView it will never show.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,943 questions
{count} votes