Open a popup window from Silverlight
Posted
by Emanuele Bartolesi
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Emanuele Bartolesi
Published on Thu, 24 Nov 2011 13:59:32 GMT
Indexed on
2011/11/25
1:54 UTC
Read the original article
Hit count: 208
Silverlight has a method called HtmlPage.PopupWindow() that opens new web browser window with a specific page.
You can find this method in the namespace System.Windows.Browser.
If you haven’t in your project, add a reference to System.Windows.Browser.
The method HtmlPage.PopupWindow() has three parameters:
- Uri – location to browse
- String – the target window
- HtmlPopupWindowOptions – a class with the window options (full list of properties http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpopupwindowoptions(v=vs.95).aspx)
For a security reason of Silverlight the call to HtmlPage.PopupWindow() is allowed through any user input like a button, hyperlink, etc.
The code is very simple:
var options = new HtmlPopupWindowOptions {Left = 0, Top = 0, Width = 800, Height = 600}; if (HtmlPage.IsPopupWindowAllowed) HtmlPage.PopupWindow(new Uri("http://geekswithblogs.net/"), "new", options);
The property IsPopupWindowAllowed is used to check whether the window is enabled to open popup.
© Geeks with Blogs or respective owner