Loading Local HTML with WebView Xamarin Forms

前端 未结 5 1107
离开以前
离开以前 2021-01-19 20:11

I am trying to load a local HTML page in a webview with Xamarin forms. I am using the basic example in the dev docs although I can get a URL to load I can\'t get my own HTML

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-19 20:31

    I am also suffering with the same issue,but I resolved in the following way

    Use "UrlWebViewSource" instead of "HtmlWebViewSource"

    var urlSource = new UrlWebViewSource();
    
    string baseUrl = DependencyService.Get().GetBaseUrl();
    string filePathUrl = Path.Combine(baseUrl, "imprint.html");
    urlSource.Url = filePathUrl;
    WebBrowser.Source = urlSource;
    

提交回复
热议问题