Visual Studio 2015 won't display local web pag

2019-09-05 05:08发布

I'm converting an app to run as a Universal Windows App using VS 2015 Community. If I create a webview using the toolbox, I can enter "http://www.google.com" into the Source property, and it will display google.

If I use the drop down on the Source property to reference (say) Help.htm as a local resource, the source windows displays "ms-appx:///Help.htm". Similarly if it is in Assets, it displays "ms-appx:///Assets/Help.htm". When I run the program, where the webview should appear it displays "You will need a new app to display this ms-appx" and invites me to search the store.

I can display a local image in an image box with very similar syntax, with Source being "ms-appx:///Assets/StoreLogo.png". The Source property in this case is in the "common" group, not "miscellaneous", but apart from that appears virtually identical.

Nor can I specify a local path in a URI (although again I can display Google). Behaviour is identical on two different machines. I have spent several days trying to work out what is going on; any suggestions?

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-05 06:08

Can you please try to load file through code and share results?

public MainPage()   
{  
    this.InitializeComponent();  
    mywebview.Source = newUri("ms-appx-web:///Help.htm");  

}  

also try this

mywebview.Navigate(newUri("ms-appx-web:///Help.htm")); 

If both above options doesn't work. Please change to below and share results

mywebview.NavigateToString("<Html><Body><h1>Eureka!!!!<h1><Body></Html>"); 
查看更多
登录 后发表回答