Luca Lindholm
Luca Lindholm

Reputation: 821

UWP/Windows 10 scenario - How to open multiple Photo windows with multiple images launched with Launcher class?

In an app of mine, I have noticed that when I open multiple image files with the Launcher class, they just open in the same Photo window, overriding itself.

Do you know a way on how to open each image file in a new Photo window?

I already know that the Launcher functions have an option class that can be added to specify launching options... and I have already played a little bit with it, but I didn't come up with any solution.

Do you know something else or how to use the Launcher option class?

Thank you so much and best regards.

Upvotes: 0

Views: 149

Answers (1)

Anran Zhang
Anran Zhang

Reputation: 7727

Do you know a way on how to open each image file in a new Photo window?

You mean how to launch multiple Photo application windows via Launcher.LaunchUriAsync()?

Here is Microsoft's public link to the Photo application, there is no content about launching multiple windows.


But you can write multi-window code for your app, open another window to display it when you open the image.

private async void Button_Click(object sender, RoutedEventArgs e)
{
    CoreApplicationView newView = CoreApplication.CreateNewView();
    int newViewId = 0;
    await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        Frame frame = new Frame();
        frame.Navigate(typeof(ShowImagePage), null);   
        Window.Current.Content = frame;
        // You have to activate the window in order to show it later.
        Window.Current.Activate();

        newViewId = ApplicationView.GetForCurrentView().Id;
    });
    bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
}

Here is the document about multiple views.

Best regards.

Upvotes: 1

Related Questions