tags:

views:

137

answers:

4

I'm trying to find a definitive "no", but have been unsuccessful. Ideally, I'd like to have my Silverlight applications pawn additional windows. I don't mean ChildWindows that are limited to the boundary of the host Silverlight window, but a truly separate window that could even appear in the taskbar. In WPF, you use System.Windows.Window and its properties (e.g. ShowInTaskbar); however, that class it not available to Silverlight.

Ideally, my application would spawn separate windows, much like Outlook does when you open the full details of a Contact or Appointment. I don't want a separate browser Window hosting a separate view of the Silverlight application (in theory, this could work via some tricky DOM-level JavaScript inter-window communication).

My assumption that this is one of the calculated limitations of Silverlight. But before I give up, I'd like to hear it from someone else that, no, I can't spawn a separate top-level window.

+1  A: 

No, you can't spawn a separate top-level window.

The best you could do is use a HyperlinkButton to open a new browser window containing another Silverlight plugin.

KeithMahoney
Thank you for verifying my suspicions!
Trinition
+2  A: 

You could open another browser window (via JavaScript call) that would contain same XAP and make your Silverlight application at startup determine what view it should display. The communication between this new child window and the main one would be done not via DOM-level JavaScript but via Local Messaging which is very simple to use.

PL
That is interesting and I'll definitely look into this. Thanks!
Trinition
A: 

I haven't had a reason to try it yet, but you could try creating additional Silverlight controls inside the browser where your main app is hosted.

Microsoft has a Silverlight.js library that makes it fairly easy to add Silverlight controls to your HTML DOM on-the-fly using Javascript.

You could float DIVs in your HTML doc for the windows, or use a simple tab control such as Jquery Tabs. Adding tabs dynamically looks pretty easy.

This would probably be the closest you could get to having multiple "windows", and it would still feel like a nice, modern web app. I'd do some careful performance testing, though, especially if your XAP file is large.

Chris Jaynes
A: 

I don't think it's possible to spawn separate windows within one silverlight application.

You could construct your application from multiple smaller xap files, using Prism for example. This would make the initial download smaller and enable you to show parts in different browser windows.

Showing a separate browsor window is pretty easy from code. Have a look at System.Windows.Browser. In the end, all you need is something like this to open a new window:

HtmlPage.PopupWindow(new Uri("http://localhost/Email.xap?showmessage=1234"), 
                     "_blanc", new HtmlPopupWindowOptions());
Sorskoot