Kumar
Kumar

Reputation: 864

Can I load XHTML file in webview in store app?

Right now I am loading HTML file in webview by placing into the Assets folder(it's working fine).. if I try do like that for XHTML file it is displaying as blank in webview.

Question: Can I load XHTML file in webview in store app from local drive?

Any help needed...

Upvotes: 1

Views: 957

Answers (1)

Farhan Ghumra
Farhan Ghumra

Reputation: 15296

Basically the problem is XHTML document does not become part of project as its build action is set to None. You have to include it. To do follow this steps.

  1. Right click on that XHTML document & click on property.

  2. Open combo box of property "Build Action"

  3. It has default "None", change it to "Content"

  4. That's it. Test and reply back. If it works, don't forget to mark it as answer.

UPDATE 1

Load XHTML from assets

MyWebView.Source = new Uri("ms-appx-web:///Assets/test.xhtml");

Load XHTML from local folder :

var XHTML = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("test.xhtml");
MyWebView.NavigateToString(await Windows.Storage.FileIO.ReadTextAsync(XHTML));

Upvotes: 2

Related Questions