Why not have a WebView have implement ContentSize(to get clientHeight) property like in ScrollView?

N_BauaN_Baua INMember ✭✭✭✭✭

Hi folks,

I know sometimes, I'm just too demanding, however this is the way I am.
I had a project requirement which required me to integrate few WebViews which need to show static as well as dynamic HTML content.

I am new to XF(So Xamarin too) and followed the practices as per documentation and I was happy to see pages implemented nicely, till the time I noticed some weird scrolling behaviour of WebView.

So this case was I have WebView1 with 500 lines approx and WebView2 with 8000+ lines.

Open WebView2 - scrolls nicely to the content - without HeightRequest property set.
Open WebView1 - scrolls nicely to the content - without HeightRequest property set.
Open WebView2 Again - scrolls only till the WebView1's client height.

So what I did to resolve?

Read through the forums and amazingly found so many threads still in pooh suggesting custom render and what not!!!
( FYI, I tried the custom render for android and its slow at least for 8000+ lines html content)

So I took the things other-way, I know it may not be the best practice to get the work done, but at least its simple and does what it says.

  • Made Http request and got the HTML string
  • I created in memory Label and ScrollView
  • Assigned HTML to Label's Text property and added to ScrollView
  • Found out the [Client] Height of ScrollView and assigned the same to the 'HeightRequest' property of WebView.

So the point is with such a simple approach, if we can have the WebView work nicely why take the pain of Custom renders which kill the motto of XF's cross platform?
Also Why can't the WebView just have in-built properties 'ContenSize' or 'ClientHeight' exposed.

I guess Xamarin team must have seen this coming or still waiting for some more features built along-side until next few releases.

N Baua

Sign In or Register to comment.