0

So, I wanted to display html pages on a WebView in my Xamarin.Forms app. The html pages contain numerous images which are locally stored (PersonalFolder on Android & iOS and WindowsStorage LocalFolder on UWP).

For Android it works very well (not tested on iOS yet) and I can display the images. However it doesn't seem to be working on UWP. After some research on multiple forums I concluded that the only way to display images on a WebView via html string is to convert the images to Base64 string.

And this actually works, but the process of reading the image from the disk and converting to Base64 takes a while than I would expect (even on a high-end PC). The other option I had is to save the Base64 string in to my SQLite db, but here my concern is the db will grow drastically.

My images are dynamically downloaded from the web and can not be included in "Assets" folder as part of the project.

Can anyone help me understand, if these are the only ways? Any better alternatives? I wish I could display images on UWP just like I could on Android.

My Helper
  • 707
  • 1
  • 10
  • 20
  • Have you take a look to a library like [FFImageLoading](https://github.com/luberda-molinet/FFImageLoading) – Leze Apr 06 '17 at 06:54
  • I am already using FFImageLoading. However I think this is to use only with XAML but not with html on a webview. Correct me if I am wrong! – My Helper Apr 06 '17 at 07:05
  • You're right, i think i read wrong your actual problems, my bad – Leze Apr 06 '17 at 07:10
  • You're probably already seens this answer with your search, but custom URI resolver seems to be the solution to avoid base64 image. – Leze Apr 06 '17 at 07:18
  • @Leze Do you have a link to that? – My Helper Apr 07 '17 at 14:07
  • Can anyone be of help? – My Helper Apr 08 '17 at 01:42
  • Have you take a look to this post [41401047](http://stackoverflow.com/questions/41401047/display-local-images-in-uwp-webview-control) – Leze Apr 08 '17 at 17:53
  • Yes, I did see this. However this is post not about Xamarin.Forms but the UWP app. They actually use webview.Navigate() and not NavigateToString(). I figured out the local path doesn't work when we use the latter method. So this will not work for us. I don't want to use a Cusomter Renderer at this point. Thanks though! – My Helper Apr 10 '17 at 00:54

0 Answers0