Pagecontainer: Correctly identify the current page as a dialog

(cherry picked from commit ba428b092ad5a94906405738c193af772febe5f9)

Closes gh-7541
Fixes gh-7538