Saravana Kumar
Saravana Kumar

Reputation: 379

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.

Upvotes: 6

Views: 904

Answers (1)

Alamakanambra
Alamakanambra

Reputation: 7881

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

Upvotes: 5

Related Questions