Reputation: 1012
I am trying to load a local html file into a WebBrowser control. However, the resources that come with that html are added to the project but not loaded in the html. I copied them in the same directory, marked them as "copy-always" resources.
Since I am new to windows phone development, any help will be greatly appreciated. Thanks.
Upvotes: 0
Views: 1575
Reputation: 11
(Assuming you have Help.html file in 'Help' folder of your project.)
var rs = Application.GetResourceStream(new Uri("/Help/Help.html", UriKind.Relative));
StreamReader sr = new StreamReader(rs.Stream);
string htmlText = sr.ReadToEnd();
sr.Close();
webBrowser1.NavigateToString(htmlText);
var rs = Application.GetResourceStream(new Uri("/YOUR_PROJECT_NAME;component/Help/Help.html", UriKind.Relative));
StreamReader sr = new StreamReader(rs.Stream);
string htmlText = sr.ReadToEnd();
sr.Close();
webBrowser1.NavigateToString(htmlText);
Upvotes: 1
Reputation: 4859
Mark the build action for file as 'Content' from 'Properties' and then try the following :
(Assuming you have b.html file in 'html' folder of your project.)
var rs = Application.GetResourceStream(new Uri("html/b.html", UriKind.Relative));
StreamReader sr = new StreamReader(rs.Stream);
string htmlText = sr.ReadToEnd();
sr.Close();
webBrowserCtrl.NavigateToString(htmlText) ;
Upvotes: 1
Reputation: 1417
You should mark the HTML File as Content. It should be "Resource" right now.
Upvotes: 0