Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrolling in .NET MAUI sometimes not possible in webview

I am showing 2 different documents of the same length in a webview, however 1 document respects the heightrequest(kinda) and is scrollable, the other ignores it and does not scroll. I am uncertain as to what is the cause of this.

EDIT: I have created a github with the (slightly edited) documents this way you guys can just clone it. To change the contract you can just change the htmlwebviewsource html https://github.com/MaoUyen/wtf

In my xaml i have the following code in my content

 <VerticalStackLayout>
        <HorizontalStackLayout Spacing="200"  VerticalOptions="Start" HorizontalOptions="Center">
            <Button Text="Cancel" Clicked="Cancel_Clicked" BackgroundColor="#8244E7" TextColor="White" FontSize="Large" WidthRequest="120" HorizontalOptions="Center"/>
            <Button Text="Sign" Clicked="Sign_Clicked" BackgroundColor="#8244E7" TextColor="White" FontSize="Large" WidthRequest="120" HorizontalOptions="Center"/>
        </HorizontalStackLayout>

        <WebView x:Name="Pagina"  HeightRequest="50000">
        </WebView>

in my cs i have the following code

    protected override void OnNavigatedTo(NavigatedToEventArgs args)
    {
        string string1 = "long html doc i cant fit in here";
        string string2 = "long htmldoc2 that i cant fit either";
        Pagina.Source = new HtmlWebViewSource { Html = string1 };

    }

    private async void Sign_Clicked(object sender, EventArgs e)
    {
        await Shell.Current.GoToAsync("page");

    }

    private async void Cancel_Clicked(object sender, EventArgs e)
    {
        await Shell.Current.GoToAsync("page2");
    }

can anyone help me make heads or tails of why it doesnt just show the content completely of both?

i tried to add some parameters to the webview like heightrequest, i tried to put in a scrollview (it stopped scrolling) without anything else the webview seems to work correctly but i need to have buttons to be able to go to the signing page...

I just want to be able to see my 2 page htmldoc in my webview and then click on the sign button.

EDIT: I have created a github with the (slightly edited) documents this way you guys can just clone it. To change the contract you can just change the htmlwebviewsource html https://github.com/MaoUyen/wtf

like image 281
ItsProbablySomethingStupid Avatar asked Dec 18 '25 18:12

ItsProbablySomethingStupid


1 Answers

alright so i took a long break and tried something else this seems to work i don't understand why a verticalstacklayout generates so much problems but the grid seems to resolve this issue

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <HorizontalStackLayout Spacing="200"  VerticalOptions="Start" HorizontalOptions="Center">
        <Button Text="Cancel" Clicked="Cancel_Clicked" BackgroundColor="#8244E7" TextColor="White" FontSize="Large" WidthRequest="120" HorizontalOptions="Center"/>
        <Button Text="Sign" Clicked="Sign_Clicked" BackgroundColor="#8244E7" TextColor="White" FontSize="Large" WidthRequest="120" HorizontalOptions="Center"/>
    </HorizontalStackLayout>

    <WebView x:Name="Pagina" Grid.Row="1">
    </WebView>
</Grid>
like image 144
ItsProbablySomethingStupid Avatar answered Dec 21 '25 07:12

ItsProbablySomethingStupid