Reputation: 3258
As the title states, I am building a Windows Universal app and am attempting to load a .html file that is a part of my app package but I am unable to.
The app pops up a dialog that says I need to find another app in the store to open this ms-appx when it is run.
I have specified .html among my file type declarations and at this point I am out of ideas. What am I missing?
I'll add some additional bits of information:
When specifying the source via the XAML designer the autogenerated property is: Source="ms-appx:///Assets/MyFile.html"
I have created a custom ContentDialog control and this is where I am attempting to load my WebView with the .html asset. The interesting thing is that when I modify my Source property to be ms-appx-web
in a normal XAML Page element this properly displays my file. However when I do the same thing, the ContentDialog still shows nothing.
Not really sure what would cause the discrepancy.
Upvotes: 2
Views: 683
Reputation: 2901
Here is a quick sample tell me if this help you:
I have an Html file in my Assets folder called MyHTMLPage, it has a build action of type content and a Copy to Output to Copy Always. My Html file:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div style="background-color: chartreuse">HELLO WORLD, from a webview</div>
</body>
</html>
On my Main Page.xaml:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<WebView x:Name="MyWebView" Width="200" Height="300"></WebView>
</Grid>
On my Main Page.cs:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
string src = "ms-appx-web:///Assets/MyHTMLPage.html";
this.MyWebView.Navigate(new Uri(src));
}
}
and Voila this should work, you should see something like this: Its not pretty ^^:
Upvotes: 1
Reputation: 120
Just an idea. How is your HTML-File included in the Project? See properties of your File --> Advanced --> Build Actíon.
Is it "Compile", "Content", "Embedded Resource". Try to Play around with that, that was sometimes a Problem in My solutions.
HTH, Oliver
Upvotes: 0