Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

how to populate a webview directly with a local html file ?

$
0
0

I did what is explained here:
https://developer.xamarin.com/guides/xamarin-forms/working-with/webview/

I wrote this code which works well:

{
    public interface IBaseUrl { string Get(); }
    public class BaseUrlWebView : WebView { }
    class LessonPage:ContentPage
    {
        public LessonPage()
        {
            BaseUrlWebView lessonWebview = new BaseUrlWebView();
            var htmlSource = new HtmlWebViewSource();
            htmlSource.Html = @"<html>
<head></head>
<body>
<p><a href=""theory_fr.html"">next page</a></p>
</body>
</html>";
            htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
            lessonWebview.Source = htmlSource;
            this.Content = lessonWebview;
        }
    }
}

What should i write to get my local html file "theory_fr.html" directly in my webview, not through a html string ?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>