UWP problems with multiple views

前端 未结 4 835
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 17:06

I am writing an app which should be able to run multiple views to edit different documents each in their own window. I\'ve wrote some code which works, but I\'m having some

4条回答
  •  误落风尘
    2021-01-02 17:20

    Actually the proper way to still be able to open up new windows after the main one is closed is to use one of the overloads provided by TryShowAsStandaloneAsync.

    protected override async void OnLaunched(LaunchActivatedEventArgs e)
    {
        // Create the newWindowId and stuff...
    
        await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newWindowId, 
            ViewSizePreference.Default,
            e.CurrentlyShownApplicationViewId, 
            ViewSizePreference.Default);
    

    Basically, you need to specify the third parameter anchorViewId which is

    the ID of the calling (anchor) window.

    In this case, you just need to pass in e.CurrentlyShownApplicationViewId.

提交回复
热议问题