最接近可与 UWP 应用一起使用的模态对话框的是什么? [英] What is the closest thing to a modal dialog that can be used with a UWP app?
问题描述
在我的 UWP 应用中,我需要从用户那里获取信息以存储在数据库中.当然,在标准 Windows 中,这很容易,只需创建一个模态对话框窗体并在需要时将其实例化即可.
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.
但在 UWP 中,虽然有对话框,但它们似乎仅限于最小和受限的功能.
But in UWP, although there are Dialogs, they seem limited to minimal and constrained functionality.
我想要的是至少类似于模态对话框的东西,用户可以在其中输入信息,然后我可以用来插入数据库,但我在 UWP 中可以看到的最接近的东西是一个页面控件,我认为,将有效地替代"主页(临时),如果我为此目的创建了一个,然后在我需要从用户那里获取输入时将其激活.这是使用 UWP 应用执行此操作的唯一公认方法还是有更好的方法?
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?
推荐答案
您可以使用 ContentDialog 类来实现与模型对话框类似的行为.
You can use ContentDialog class to implement similar behavior as a model dialog.
参考上述文档中的SignInContentDialog.xaml
部分,您可以添加任意的UI控件来获取面板内的用户信息(例如StackPanel
或>Grid
) 在 ContentDialog
中,您还可以在面板中设置 ContentDialog
的大小.
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.
您可以通过添加 PrimaryButtonClick
和 CloseButtonClick
事件处理程序来处理来自用户的数据(PrimaryButtonClick
和 CloseButtonClick
是ContentDialog
) 或其他 Button
控件的默认控件.
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.
这篇关于最接近可与 UWP 应用一起使用的模态对话框的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!