title: Display local html file content in UWP WebView
body: <p>I believe this is pretty straightforward task and I've seen a lot of examples in the web but still none of them is working for me since I experience different exceptions.</p>
  
  <p><strong>html:</strong></p>
  
  <pre><code>&lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;
          Help html content.
      &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>xaml:</strong></p>
  
  <pre><code>&lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition/&gt;
              &lt;RowDefinition Height="30"/&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;WebView x:Name="webView" /&gt;
          &lt;Button x:Name="buttonRefresh" 
                  Grid.Row="1" 
                  HorizontalAlignment="Center"
                  Click="buttonRefresh_Click"&gt;
              Refresh
          &lt;/Button&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>To display static html saved in <code>help.html</code> file in my UWP application LocalFolder I've already tried the following:
  <br>
  - <strong>Use Navigate method:</strong></p>
  
  <pre><code>private void buttonRefresh_Click(object sender, RoutedEventArgs e)
          {
              var uri = new Uri("ms-appdata:///local/help.html");
              webView.Navigate(uri);
          }
  </code></pre>
  
  <p>and the result is the following exception:</p>
  
  <pre><code>System.ArgumentException: Value does not fall within the expected range.
     at Windows.UI.Xaml.Controls.WebView.Navigate(Uri source)
     at SimpleUwpApp.Proxy.SimplerPage.buttonRefresh_Click(Object sender, RoutedEventArgs e)
  </code></pre>
  
  <p><br>
  <strong>- Try to set Source property of webView explicitly in code behind:</strong></p>
  
  <pre><code>private void buttonRefresh_Click(object sender, RoutedEventArgs e)
  {
      var uri = new Uri("ms-appdata:///local/help.html");
      webView.Source = uri;
  }
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>System.ArgumentException: Value does not fall within the expected range.
     at Windows.UI.Xaml.Controls.WebView.put_Source(Uri value)
     at SimpleUwpApp.Proxy.SimplerPage.buttonRefresh_Click(Object sender, RoutedEventArgs e)
  </code></pre>
  
  <p><br>
  <strong>- Set Source property of webView explicitly in xaml:</strong> This is the exact example from <a href="https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.WebView" rel="noreferrer">microsoft documentation</a>.</p>
  
  <pre><code>&lt;WebView x:Name="webView" Source="ms-appdata:///local/help.html" /&gt;
  </code></pre>
  
  <p>As a result exception on startup:</p>
  
  <pre><code>Windows.UI.Xaml.Markup.XamlParseException: The text associated with this error code could not be found.
  
  Failed to assign to property 'Windows.UI.Xaml.Controls.WebView.Source' because the type 'Windows.Foundation.String' cannot be assigned to the type 'Windows.Foundation.Uri'. [Line: 16 Position: 54]
     at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
     at SimpleUwpApp.Proxy.SimplerPage.InitializeComponent()
  </code></pre>
  
  <p><br>
  <strong>- Tried using url string directly in <code>Navigate()</code> arguments as in this <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview#Windows_UI_Xaml_Controls_WebView_Navigate_Windows_Foundation_Uri_" rel="noreferrer">microsoft examples</a> but <code>Navigate()</code> accepts only <code>Uri</code> as an aargument so the documentation is either invalid, either for older version of xaml toolkit.</strong></p>
  
  <pre><code>webView.Navigate("ms-appx-web:///help.html");
  </code></pre>
  
  <p>result: </p>
  
  <pre><code>Syntax error.
  </code></pre>
  
  <p>The only solution I've temporary came up with is reading the content of html file with some kind of file manager and using <code>NavigateToString()</code> method:</p>
  
  <pre><code>var content = fileManager.Read("help.html"); // Manually read the content of html file
  webView.NavigateToString(content);
  </code></pre>
  
  <p><br>
  <strong>So the question is why described examples don't work? How to avoid using NavigateToString?</strong></p>