microsoft / InventorySample

Sample UWP application for LOB scenarios
MIT License
591 stars 199 forks source link

Main Window switch Page during Secondary Window Consolidation #34

Closed codingdna2 closed 6 years ago

codingdna2 commented 6 years ago

Repro steps

If I break on source code while a secondary window is open, it navigates the main window to a blank page. I've traced the issue to this piece of code:

    private void OnViewConsolidated(ApplicationView sender, ApplicationViewConsolidatedEventArgs args)
    {
        ViewModel.Unsubscribe();
        ViewModel = null;
        Bindings.StopTracking();
        frame.Navigate(typeof(Page));
        var appView = ApplicationView.GetForCurrentView();
        appView.Consolidated -= OnViewConsolidated;
        ServiceLocator.DisposeCurrent();
    }

As a workaround I've commented the frame.Navigate line.

Actual Behavior

Following is a video on how to reproduce the issue:

issuemainview

System

Visual Studio 2017 Windows 10 Build 1803

codingdna2 commented 6 years ago

Related to this issue there's one more (let me know if I should create an additional issue).

The secondary Window is kept on the Live Tree and it's not disposed. I've added to the above method a call to Window.Current.Close(); in order to fix it but I don't know if it's the right solution. Please advise.

dishantmshah commented 6 years ago

@codingdna2 Solution you suggest seems to be working correctly, you can raise a PR with the fix.