1
votes

I'm trying to implement WebView that changes it's height dynamically in a ListView. I'm using Xamarin forms (PCL) with separate project for iOS and Android mainly for custom renderers.

I've tried to follow the solution stated here: https://forums.xamarin.com/discussion/comment/184948/#Comment_184948

The way he implemented it is that he wait 100ms for the WebView to be rendered, then changes the WebView height according to the height of the content.

In my case, since the webView is inside a ListView item, the height of the ListView item is not adjusted accordingly (the WebView goes outside the boundary of the ListView item).

My question is, how do i modify the height of the ListView items when the WebView height inside is modified?

Thank you for helping me!

1

1 Answers

0
votes

how do i modify the height of the ListView items when the WebView height inside is modified?

Please set the listview attribute HasUnevenRows = "True" RowHeight="-1"

As the following code the webview height and weight is modified as 100, the listview will warp the webview when you set HasUnevenRows = "True" RowHeight="-1"

<ListView x:Name="listView" HasUnevenRows = "True" RowHeight="-1" >
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout   Orientation="Horizontal" >
                        <WebView HeightRequest="100" WidthRequest="100" Source="http://www.google.com/" />
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

screen shot:

enter image description here