Quantcast
Channel: Geekswithblogs.net
Viewing all articles
Browse latest Browse all 6441

Open a popup window from Silverlight

$
0
0

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:

  1. Uri – location to browse
  2. String – the target window
  3. 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.


Viewing all articles
Browse latest Browse all 6441

Latest Images

Trending Articles



Latest Images