1

My primary concern here is to know how to launch another instance of my UWP app from the same app itself, some code snippet or documentation link would be helpful.

Below are the changes suggested by different links, but didn't found any thing concrete:

Appraoch:

Research suggest that we can launch multiple instance of the same UWP application by setting the package.appxmanifest file with flag SupportsMultiInstances to True. Link here

<Application Id="App"
  ...
  desktop4:SupportsMultipleInstances="true"
  iot2:SupportsMultipleInstances="true">
  ...
</Application>

Extension

We can set the uap:FileTypeAssociation for these apps and later run the instance of the app which we wish. But these are already build files and I need to open new instance at runtime from my uwp app.

URI:

One more way was to open store app using URI.

var uriToLaunch = "testapp-mainpage://";
var uri = new Uri(uriToLaunch);
bool success = await Windows.System.Launcher.LaunchUriAsync(uri);

Now based on this, the way I wish to launch second or another instance of my app is something like below:

Suppose I have an UWP app which have first view to select type of user from dropdown having Agent, Owner and GuestUser. based on that I show list of House properties to user on next page.

Now I would like to have the functionality where, when user press and hold on a house property card then the details to purchase it and other booking page(s) are visible on another instance(where selecting the type of user and selecting the house property is skipped). while if user just click once (not long-press) on a house property card then it will open in the same instance.

SideNote

I am not looking for MultipleView where we show independent part of your app in separate window.

Ankit Dhadse
  • 1,566
  • 1
  • 15
  • 19
  • The URI launch works for me. Why is that not an option for your scenario? – Stefan Wick MSFT May 18 '18 at 01:56
  • @StefanWickMSFT - I am using Template10 for the app and it does not have a static class to catch the URI. neither does it support overriding OnLaunched or OnActivated as they are sealed. – Ankit Dhadse May 20 '18 at 16:47
  • With Template10 you should be able to override OnStartAsync in order to handle URI protocol launch: https://github.com/Windows-XAML/Template10/wiki/Bootstrapper#activation-paths – Stefan Wick MSFT May 20 '18 at 22:44
  • Yes, and how to handle static class. I added static Main to my app and launched `App` from there. but my app never hits the Main. am I missing anything. I have also added `DISABLE_XAML_GENERATED_MAIN` to the proj file. – Ankit Dhadse May 21 '18 at 06:46
  • Did you take stefan's suggestion to override `OnStartAsync` method? Why you need to add static main? OnStartAsync is the one and only entry point to an application that is not resuming from suspension. – Sunteen Wu May 25 '18 at 07:59

0 Answers0