windows-8 - 将本地HTML加载到WebView中

标签 windows-8 microsoft-metro

我可以将本地HTML文件(带有图像和...)加载到WebView吗?
仅设置Source参数并不能解决问题。

最佳答案

只要文件是应用程序包的一部分,就可以从文件中加载它,例如:

WebView2.Source = new Uri("ms-appx-web:///assets/text.html");

WebView.Navigate

WebView can load content from the application’s package using ms-appx-web://, from the network using http/https, or from a string using NavigateToString. It cannot load content from the application’s data storage. To access the intranet, the corresponding capability must be turned on in the application manifest.



对于“随机”文件,我想您可以通过文件选择器提示用户选择文件,然后将其读入字符串并使用NavigateToString,但是根据您要完成的操作,用户体验可能会有些奇怪。

关于windows-8 - 将本地HTML加载到WebView中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13225796/

相关文章:

c# - 无法访问 Windows Phone 中的 MessageBox 类

c# - 更改 GridView 标题位置

C#、Metro、Stream Socket、SSL 不可信主机、Squid

c# - 如何在 WinRT 中将 VirtualKey 转换为非美式键盘布局的字符?

windows-8 - Windows 8 中可以降低应用栏的高度吗?

windows - 在 Windows 8 中从 Metro 应用程序触发关机/重启的最佳方式

c# - Windows 8 Developer Preview 中缺少 Type.GetProperty() 方法

xaml - Windows 8 Metro : Implementing Validation

windows - Metro 应用程序可以知道其他应用程序吗?

windows-8 - 我的应用程序的试用用户可以使用我的应用程序内购买吗?