How to create a new window in UWP

---
date: Feb 07, 2016
tags:
-
-
---

Some friends of mine asked me how to create a window in UWP just like WinForms or UWP, to make their app more desktop-like. Actually, it is pretty simple.

new window in UWP

I cannot say this is difficult or simple. In order to open a new window, You need to use CoreApplication.CreateNewView() to generate the Window, or view:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var currentAV = ApplicationView.GetForCurrentView();

await newAV.Dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
async () =>
{
var newWindow = Window.Current;
var newAppView = ApplicationView.GetForCurrentView();newAppView.Title = title;  //The title of new windowvar frame = new Frame();
frame.Navigate(typeof(Page), Datatosend); //Navigation is here
newWindow.Content = frame;
newWindow.Activate();await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
newAppView.Id,
ViewSizePreference.UseMinimum,
currentAV.Id,
ViewSizePreference.UseMinimum);
});

Navigation


Creative Commons License
Unless specified, all the articles are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Free Software Fundation Member

The site is proudly powered by Hexo hosted on GitHub Pages.

The site is powered by the glorious CSS from bettermotherf**kingwebsite.com with some tweaks. Censored the f-word for good.

Main | Access | CDN | RSS | Sitemap
2008 - 2020 | Patrick WU Jinming