Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The NavigateToString method doesn't work with tags that point to images in the LocalData folder. (as far as I recall anyway). In fact NavigateToString also breaks JavaScript and CSS links.</p> <p><strong>Images on Server</strong></p> <p>One solution, is to change your source to point to a network server instead of localdata. I'm not sure it that works for your app scenario though.</p> <p><strong>Images and HTML as content</strong></p> <p>The second choice is to add your html and image files as content to your app and use </p> <pre><code>WebView1.Navigate(new Uri("ms-appx-web:///assets/SampleHtmlPage.html")); </code></pre> <p>to load the HTML.</p> <p><strong>In Process HTTP Server</strong></p> <p>Here is a solution that uses a custom HTTP server in the app to handle the issues.</p> <p><a href="http://blog.jsolutions.co.uk/?p=492" rel="nofollow">Loading Local HTML Content in Metro WebView (Windows 8)</a></p> <p><strong>Base 64 encoded image</strong></p> <p>Finally, there is another solution using Base64 encoding of your images in the LocalData folder. </p> <pre><code>internal async void MakeHtmlString() { StorageFile imageFile; // get image file here. var html = string.Format("&lt;div&gt;&lt;img src='data:image/png;base64,{0}'", await GetImageBase64(imageFile)); } internal async Task&lt;string&gt; GetImageBase64(StorageFile imageFile) { var imageStream = await imageFile.OpenAsync(FileAccessMode.Read); var inputStream = imageStream.GetInputStreamAt(0); var dataReader = new DataReader(inputStream); var dataResults = await dataReader.LoadAsync((uint)imageStream.Size); var bytes = new byte[dataResults]; dataReader.ReadBytes(bytes); return Convert.ToBase64String(bytes); } </code></pre> <p>This last approach works for images, but not for CSS files.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload