I have a navigation view pattern in UWP app with a "navigation root" page hosting a frame for child pages. If I call a ContentDialog
from a child page, I can still access objects in the master page if I use keyboard shortcuts. This can easily result in an app crash if another content dialog is opened.
How can I make ContentDialog
truly modal?
Project demonstrating the issue can be found here: https://github.com/under3415/NavigationApp
In a nutshell, create two pages, one hosting the other in a frame
<Frame Grid.Row="1" x:Name="RootContentFrame"/>
In a master page, have a Button
or another object with AccessKey
defined.
In a child page, call a ContentDialog
. While content dialog is open press ALT
key and then the access key. Even though the modal dialog is open, the object behind fires.
When the
ContentDialog
show, it will block interactions with the app window until being explicitly dismissed. But it could not block access keys, because are keyboard shortcuts that improve the usability and the accessibility of your Windows applications by providing an intuitive way for users to quickly navigate and interact with an app's visible UI through a keyboard instead of a pointer device (such as touch or mouse).For your scenario, we suggest make event to detect Dialog show or not then set root page
IsEnable
true or false.Make an Action in your app class
Detect Dialog open or close.
Disable or Enable Root page base dialog open or not.