简体   繁体   中英

Display local html page inside WebView

I have an html file (which consists of both text and images) in my Documents library (it need not exactly be over there, what I mean to emphasize is - it's not in the internet and not included within the app package since it's dynamic content and created after the app has been deployed).

I want to display the contents of this page within a WebView . How would I go about doing that ?

You can (and should) copy your HTML Files to the LocalState Directory of your App which sits here: C:\\Users\\YourUSerName\\AppData\\Local\\Packages\\YourApp\\LocalState.

You then can Access this with: ms-appdata:///local/

Very Basic example:

string url = "ms-appdata:///local/myWebpage.html";
webView.Navigate(new Uri(url));

You can find a lot of Information and samples in this sample download: https://code.msdn.microsoft.com/windowsapps/XAML-WebView-control-sample-58ad63f7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM