In the Universal Windows Platform you have the ability to create extra windows for your app that can display or handle different parts of the app using CoreApplication and CoreWindow, but you also have the possibility to have your app project that window or a view to a connected display using the ProjectionManager.

Examples of an app that utilize this is the Powerpoint Mobile app. Running it on a phone for instance and connecting it to an external display using Miracast/Continuum allow you to have your notes and information vital to your presentation on the phone’s display and have the actual presentation displayed on the external display.

In the last post, UWP: Keeping your display active, I showed you how you could keep an application alive and prevent the device going idle or into sleep mode if you will. In this post I will show you how you can use ProjectionManager to project a view to onto a secondary display. In my case this was my TV.

The app I created for my birthday party didn’t do anything other than keep Continuum running so that I could stream music through the TV. Since I already had to have the app running why not use it to display some content on the TV as well?

I could of course had used one page and made it responsive so it scaled great across different resolutions and/or started it from the Continuum desktop, but I didn’t want to have any content on my phone’s display, just the TV, because; why make it easy, right?. Also if I had done that I wouldn’t have had anything interesting to write about.

Since I was short on time before the party started I wanted to display some white text on a black background and when it was getting time to move the party elsewhere it would transition to a white background with black text that hinted to us that it was time to order a cab.

The page and the logic itself was easy to create, but the projection stuff I had never done before. The steps required to do this is:

  1. You have to check if a projection display is available
  2. Create a new view (window)
  3. Set the content for the new view
  4. Try to project the view onto the projection display

Turns out it is pretty straight forward:
UPDATE 29th May 2016: A big thank you goes to Bjorn Eriksen (@bjorn_eriksen) for pointing out that the previous code threw a COM exception with the latest Windows 10 bits. We verified this on the latest Windows 10 update for consumers. As such we have updated the snippet to include the fix

Two things to notice here is that we need to retrieve the window identifiers for both views: the one initiating (current window) the projection and the new view. We also have to set the content of the newly created view inside of its UI thread hence the Dispatcher.

That’s the basics of it. Hopefully you’ve gotten some app ideas where this can be utilized and be useful as well. It opens up a lot of possibilities when using Continuum or having TVs or projectors connected.

As always; if you have feedback of any kind feel free to comment!