Display HTML String in HybridWebView

daalboodaalboo Member ✭✭

I created HybridWebView from this link.
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview
I am trying to display HTML String instead of url. I tried

string aa = "<!DOCTYPE html> <head> <body> <div > <h1>hello</h1> </div> </div> </body> </html>";
            hybridWebView.Uri = aa; 

Also

hybridWebView.Source = new HtmlWebViewSource { Html = aa };

//HybridWebViewRenderer
Control.LoadUrl($"{((HybridWebView)Element).Source}");

Best Answer

  • daalboodaalboo ✭✭
    edited February 15 Accepted Answer

    This is how i found solution.
    //HybridWebViewRenderer
    Control.LoadData($"{((HybridWebView)Element).Uri}", "text/html", null);

    Use
    string aa = "HTML TEXT";
    hybridWebView.Uri = aa;

Answers

  • daalboodaalboo Member ✭✭
    edited February 15 Accepted Answer

    This is how i found solution.
    //HybridWebViewRenderer
    Control.LoadData($"{((HybridWebView)Element).Uri}", "text/html", null);

    Use
    string aa = "HTML TEXT";
    hybridWebView.Uri = aa;

Sign In or Register to comment.