How to open a “new window” in a Windows 10 Universal App
I had to dig a little bit to find this. Since not all form factors support multiple windows and tablet mode generally discourages floating windows this is probably buried for a reason, but I wanted to do it anyway so here it is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var viewId = 0;
var newView = CoreApplication.CreateNewView();
await newView.Dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
() =>
{
var frame = new Frame();
frame.Navigate(typeof(YourViewPageType), ViewModelDataOrNull);
Window.Current.Content = frame;
viewId = ApplicationView.GetForCurrentView().Id;
ApplicationView.GetForCurrentView().Consolidated += App.ViewConsolidated;
Window.Current.Activate();
});
var viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(viewId);
Hopefully that will save someone some digging.
This post is licensed under CC BY 4.0 by the author.