-
Silverlight 4 “Pop-out” window
Introduction
Recently in a business-line Silverlight OOB application in my professional work, a requirement came across the wire to add the ability to be able to create a “pop-out” window which would allow the user to click a button which would spawn a separate window of the current application which keeping the current application’s window open. Furthermore, the user would then use the current window and actions performed by the user in this window would affect what the user sees in the spawned window (and possibly vice-versa). An additional requirement is the possibility to use this setup in a multi-monitor environment where the current application exists full-screen in one monitor will the spawned application exists full-screen in a second monitor… this scenario is probably the most commonly needed scenario I would think so I wanted to get this information out there for everyone to possibly entertain usage in their application(s).
If you don’t care about the details, just grab it here.
To contact me, click here
Description
This functionality has a few limitations listed in a later section but to put it short and sweet, this can only be applied to a Silverlight 4 OOB Full-trust application. If this is what you want/need, then you’ve come to the right place. So here’s how this demonstration code breaks down:
- One single Silverlight 4 application installed OOB with full-trust
- A control to capture/respond to an event (mostly user initiated)
- A button to capture the intended event of spawning a separate window
- 2 different “modes” of usage – one being as a singular application, the other as the “spawned” application
- Usage of LocalMessageSender/LocalMessageReceiver for communication between the Silverlight applications (completely client-side!)
- Filesystem usage to the ‘My Documents’ folder of the client machine (I know, it sucks that Silverlight doesn’t let us a temp folder somewhere like AppData\<current product> with full RW access but at least this app cleans up the files after use)
- A button to showcase the fullscreen capabilities
So you’ll see the application show itself as a single instance and function normally as well as allow the user to click a button to spawn itself into a second instance with a different view and both instances will react to user interaction and communicate with each other accordingly. Pretty sweet… my favorite part about the whole thing is that this is actually just 2 instances of the same application so just one codebase as well as just one simple installation (and one update scenario in my particular case). Even better, the LocalMessageSender\Receiver stuff is all client-side so you aren’t bogging down network traffic as you send messages between the applications.
Oh, and by the way, there are plenty of implementations of this to fit your needs if you want. In my initial testing, instead of using 2 instances of the same application, my “spawn” didn’t require OOB so I simply had a separate SL4 project hosted on a URL. From the main OOB app, I executed IE via Interop and then navigated to the URL of the “spawn”. Since LocalMessageSender works for inbrowser and out-of-browser applications (and connects to both types seamlessly), I actually had my OOB app communicating with a completely separate in-browser app. All pretty fun stuff and lots of possibilities I don’t showcase in this project.
Requirements
- Visual Studio 2010 RC
- Silverlight 4 RC
- Access to install/run trusted OOB Silverlight applications
- Tested this on XP and Win7
Limitations
This application is simply a small demonstration of the capabilities here. One big thing to remember is the message is a string type that can be sent is limited to 40KB. In my complex example of serializing the ListBoxItem and sending across the wire, if that XML was greater than 40KB, I’d have a problem… so be sure you either abide by this limitation or you adjust accordingly (one example is in a DB application where one can simply send an identity for the item over to the viewer and the viewer obtains the details for that item directly from the database). You can read more about this limitation with the LocalMessageSender on MSDN.
Resources
Finally the Goods…
Download here
Here’s the app… make sure you right-click and install to your local machine to run.


