Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save henningms/056be884fe2e396183573ae203620b51 to your computer and use it in GitHub Desktop.
Save henningms/056be884fe2e396183573ae203620b51 to your computer and use it in GitHub Desktop.
UWP: Project view to another screen
// Check if we have an external display available and ready to use
if (ProjectionManager.ProjectionDisplayAvailable)
{
// Get the ID of the current window
int currentViewId = ApplicationView.GetForCurrentView().Id;
var newView = CoreApplication.CreateNewView();
// Retrieve the Projection View ID to be used in StartProjectingAsync
ApplicationView newApplicationView = null;
// Set the content for the new view
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
newApplicationView = ApplicationView.GetForCurrentView();
var rootFrame = new Frame();
rootFrame.Navigate(typeof(ProjectedScreen2));
Window.Current.Content = rootFrame;
Window.Current.Activate();
});
// Project our new view to the external display
await ProjectionManager.StartProjectingAsync(newApplicationView.Id, currentViewId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment