Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP Multiple views in single UI Thread

Currently in UWP apps multiple windows for an app are running in different UI threads, which makes development difficult (to run in the current dispatcher), In MSBuild 18 microsoft announced that now mutliple windows for the same app will run in the single UI thread. Is this feature available for when it can be expected. Because for handling new window is becoming a big pain in UWP apps.

like image 316
Saravana Kumar Avatar asked Jun 01 '18 08:06

Saravana Kumar


1 Answers

Your prayers have been answered... All the pain with multiple secondary views on different UI threads is gone.

There is new AppWindow class. It is still in preview (with some limitations), but works with 1903 (build 18362).

AppWindow appWindow = await AppWindow.TryCreateAsync();
Frame appWindowContentFrame = new Frame();
appWindowContentFrame.Navigate(typeof(SecondPage));
ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame);
await appWindow.TryShowAsync();

More info from Microsoft

Older demo app

like image 51
Alamakanambra Avatar answered Nov 08 '22 22:11

Alamakanambra