Emanuele Bartolesi

don't try this at home.
posts - 12, comments - 5, trackbacks - 0

My Links

News

View Emanuele Bartolesi's profile on LinkedIn

Emanuele Bartolesi

Create Your Badge

My status



Software tracking

Software tracking

hacker emblem

Twitter







Archives

Open a popup window from Silverlight

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.

Print | posted on Thursday, November 24, 2011 2:59 PM |

Feedback

Gravatar

# re: Open a popup window from Silverlight

Hi do you know a way where in I can open a PDF document in the popup ? I am using silverlight3 and there is this PopUpWindow that I can open anywhere, but I am not sure how to open a document in the window. - BrandStar Entertainment
2/18/2012 1:03 PM | Brandstar Entertainment
Gravatar

# re: Open a popup window from Silverlight

Hi.
You can open an Aspx page with a parameter with a document name.
In the aspx page you can open a Pdf document.

Emanuele
2/18/2012 1:10 PM | Emanuele
Gravatar

# re: Open a popup window from Silverlight

Is it possible to use the method HtmlPage.PopUpWindow() to trigger a file download, in this case a text file (.txt)?
I want to force the file download and not to open its content inside the PopUp - althought I'm afraid that the only way around is setting the content mime type.
I can't change much the aspx page code, so I'm likely stuck inside Silverlight. Any help is greatly apprecciated!

Thanks in advanced.

Alfred,
Step Down Transformer
3/31/2012 2:29 AM | Alfred Manch
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: