How to create a new window in UWP

---
date: Feb 07, 2016
tags:
- C#
- UWP
language: English
---

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.


It uses a self-hosted Open Web Analytics to get insights. Click here to optout.

The site is powered by Hexo. The source code of this website is here, so that you can see the spaghetti code behind my blog.


Main | Blog | Comic | Podcasts (Preparing) | RSS | Sitemap
2008 - 2022 | Patrick WU Jinming