Fixed an edge case where the view model ended in Page, Flyout, or UserControl.