Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Is there a way to update the style of web page displayed in a WebView with scraping?

PacodosoPacodoso FRUniversity ✭✭✭
edited October 2020 in Xamarin.Forms

I work on a small Xamarin.Forms app containing a WebView allowing users to book an appointment.

This page is managed by another provider, and there is no way to customize the CSS directly: this page is the same for all their clients, even if the URL is well related to my client. It's something like:

So I wondered if there is a way to edit the style from my side, with a scraping library like Html Agility Pack

But after a first quick test, it doesn't seem to be possible: the HTML source doesn't seem to be reinjected in the WebView as I get an empty WebView as result.

I've did this in the code-behind:

var web = new HtmlWeb();
var doc = web.Load("");
HtmlWebViewSource htmlWebViewSource = new HtmlWebViewSource()
    BaseUrl = "",
    Html = doc.Text
this.webView.Source = htmlWebViewSource;

And my XAML looks like this:

<WebView x:Name="webView" WidthRequest="1000" HeightRequest="1000" />

After having investigated with Charles Proxy, it seems that I have 2 behaviours:

  • when I open the URL through a navigator, or by passing the URL to the WebView directly, different files are loaded: the html page, and some other files (some .js scripts, a .css style, and 1 file containing API results)
  • when I call the same URL through the previous code, I only get the html page

This is certainly why I don't get the expected behaviour.

=> So, should it be possible or not? I don't see how I could achieve this...


Sign In or Register to comment.