Windows Phone 用WebBrowser加载HTML页面
方法:webBrowser.NavigateToString(string html);
一:加載程序集里面的資源信息
1.加載html資源
(1)? StreamReader reader=Application.GetResourceStream(New Uri("path",UriKind.Relative).Stream;
webBrowser.NavigateToString(reader.ReadToEnd());
(2)??引用命名空間: Microsoft.Xna.Framework;
StreamReader reader = new StreamReader(TitleContainer.OpenStream("pathString"));
webBrowser.NavigateToString(reader.ReadToEnd());
(3)? webBrowser.NavigateToString("htmlString");
注:為了讓顯示的html頁面能夠進行交互,就需要讓webBrowser具備支持腳本語言的功能,所以需要設置webBrowser.IsScriptEnabled = true;
2.加載圖片資源
二:加載程序的獨立內存空間里面的資源信息
1.加載html資源
(1)?VAR fe = IsolatedStorageFile.GetUserStoreForApplication());???????????????????
??????? IsolatedStorageFileStream stream= fe.OpenFile("BOOK.HTML", FileMode.Open, FileAccess.Read);??
? StreamReader reader=new StreamReader(stream);????????????
webBrowser.NavigateToString(reader.ReadToEnd());?
2.加載圖片資源
將網絡圖片資源保存在本地的空間上面,然后使用WebBrowser控件展示,
ProductId:Windows phone 工程中的WMAppManifest.xml中的App節點的ProductId屬性
ContentDictionary:保存在本地存儲控件的路徑
string html=""good morning good afternoon"
html=String.Format(html,ProductId,ContentDictonary);
???webBrowser.NavigateToString(html);
轉載于:https://www.cnblogs.com/lihaibo-Leao/archive/2013/06/04/3117468.html
總結
以上是生活随笔為你收集整理的Windows Phone 用WebBrowser加载HTML页面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NetBeans与myeclipse区别
- 下一篇: 关于Const指针的一点补充