What is the closest thing to a modal dialog that can be used with a UWP app?

余生颓废 提交于 2021-01-07 01:22:18

问题


In my UWP app, I need to get information from the user to store in a database. In standard Windows this is easy, of course, by creating a modal dialog form and instantiating it when needed.

But in UWP, although there are Dialogs, they seem limited to minimal and constrained functionality.

What I want is something at least similar to a modal dialog form, where the user would enter information I could then use to insert into the database, but the closest thing I can see available in UWP is a Page control which, I think, would effectively "replace" the main page (temporarily) if I created one for this purpose and then made it active when I needed to elicit input from the user. Is this the accepted only way to do this with UWP apps or is there a better way?


回答1:


You can use ContentDialog class to implement similar behavior as a model dialog.

Referring to SignInContentDialog.xaml part in the above document , you can add arbitrary UI controls to get information from the user within a panel(such as StackPanel or Grid) in ContentDialog and you can also set the size of the ContentDialog in the panel.

You can handle the data from user by adding PrimaryButtonClick and CloseButtonClick event handler(PrimaryButtonClick and CloseButtonClick are default controls of ContentDialog) or other Button controls.



来源:https://stackoverflow.com/questions/65030569/what-is-the-closest-thing-to-a-modal-dialog-that-can-be-used-with-a-uwp-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!