Add a new page to a Silverlight project
I know this may sound pretty dumb but how do I add a new webpage to the Silverlight Project?
I did a "Add new Item" and select an xam开发者_高级运维l file.
Now I want to open that file via the webbrowser. The File is called PrintPage.xaml.
private void Button_Click_1(object sender, RoutedEventArgs e)
{
HtmlPage.Window.Navigate(new Uri("PrintPage.xaml" , UriKind.Relative), "_blank");
}
Page not found error.
Xaml pages are Silverlight Pages, not Web pages. With Silverlight you are always on the same Web page, but displaying different Silverlight pages internally within the Silverlight object.
If you want to change Silverlight pages, start with either the Silverlight Navigation App or Silverlight Business App templates as an example. The Silverlight navigation systems all work using browser "bookmark" links (they have a # at the end of the HTML page) and use the parameters after the # to determine the target page. By using bookmark links the hosting web page does not get refreshed (otherwise the Silverlight application would reload).
If you actually want to go to a new web page, with a new Silverlight application, you want to add an ASPX or HTML page instead and browse to that.
Use this code
HtmlPage.Window.Invoke("ShowBrowserIFrame", url);
url is path of your hemp page, and ShowBrowserIFrame is java script function, used to open html web page.
function ShowBrowserIFrame(url) {
BrowserDivContainer.css('display', 'block');
$('<iframe id="' + jobPlanIFrameID + '" src="' + url + '" style="height:100%;width:100%;" />')
.appendTo(BrowserDivIFrameContainer);
slHost.css('width', '0%');
}
Follow this link to add html page inside silver light project.
精彩评论