Captain Sensible
Captain Sensible

Reputation: 5027

How do I open a second window and snap it (left or right) in split screen mode?

Configuration: MS Surface tablet with Windows 10 in tablet mode.

I was using the Microsoft Store App when an error occurred. A browser window (with error info in it) was automatically opened, snapped to the right of the MS Store App (see illustration below). Note the slider-bar between the two windows.

How can I do the same? Can someone show me a code sample?

enter image description here

Upvotes: 0

Views: 53

Answers (1)

Anran Zhang
Anran Zhang

Reputation: 7727

This slider only appears when two windows are placed in parallel in tablet mode.

So for the same application, you only need to create a new window, and the system will automatically split the screen display.

Code snippet like this:

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(SecondaryPage), 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);
}

There is more than one way to display a new window. For more content, please see this document.

Thanks.

Upvotes: 2

Related Questions