I have a 开发者_Go百科silverlight window, and when a button is pressed, I want to open it on a new tab\window. How can I do it?
The HtmlPage.Window.Navigate()
method has an overload which allows you to specify which frame to load the new page in. _blank
is used for new window/tab.
HtmlPage.Window.Navigate(new Uri("http://google.com"), "_blank");
Taking your question literally the answer is:-
HtmlPage.Window.Navigate(HtmlPage.Document.DocumentUri, "_blank");
Rather than using the URI like people here are suggesting you should just create an object of your page and pass it to the navigate method.
Dim yournewpage as new OrganiztrionInfoFromToolTip()
HtmlPage.Window.Navigate(yournewpage, "_blank")
You can use a HyperlinkButton for this.
<HyperlinkButton NavigateUri="http://www.silverlight.net" TargetName="_blank" Content="HyperlinkButton"/>
When you specify "_blank" as TargetName. A new tab or window is opened and the specified uri gets opened. Also other values for TargetName are valid. See here more.
Edit:
To open the same Silverlight application in a new tab you can use the System.Windows.Browser.HtmlPage.Document.DocumentUri as NavigationUri of the HyperlinkButton.
Also try this in .aspx Page
<head id="Head1" runat="server">
<title>Your Applicateion</title>
<script type="text/javascript">
var windowClose = window.close;
window.close = function () {
window.open("", "_self");
windowClose();
}
function OpenWindow() {
window.opener = 'x';
window.close();
window.open('Default.html', '_blank', 'status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=no,scrollbars=no,height=' + screen.availHeight + ',width=' + screen.availWidth + ',top=0,left=0');
return false;
}
</script>
</head>
<body onload="OpenWindow();">
<form id="form1" runat="server">
</form>
</body>
The only thing you can open 'in a new tab' is a web page. If you want to open a different Silverlight application in a new tab, then it will need to be hosted in a webpage, and you will need to use HtmlPage.Window.Navigate() to open that page. You cannot just open a new tab and have it somehow contain something embedded in your application - that is not how webbrowsers work.
精彩评论