How to have user prompt dialogs in Windows 8 metro apps?

微笑、不失礼 提交于 2019-12-10 10:11:25

问题


I would like to get some user inputs for my app like Name, DOB, etc from a modal window
for this I need a dialog to be displayed which would contain the textboxes and other controls.
Normally in WinForms/WPF I would create a class inherited from the Form/Window class and use the Show/ShowDialog method to present the form to the user
How do I achieve this behavior in Windows 8 metro apps using XAML/C# ?
I have looked at the MessageDialog class under the Windows.UI.Popups namespace
but its for showing only message like the classic MessageBox.
I have looked at another CoreWindowFlyout class and also not sure if that can be used for the behavior I am expecting.


回答1:


You can simply create a custom UserControl with all the required inputs (such as TextBoxes) and then show it using Popup class.

for example:

Popup myPopup = new Popup();
myPopup.Child = new CustomUserControl();
myPopup.IsOpen = true;



回答2:


Following on from the spot on answer from MBZ, have you tried looking at "Windows 8 app samples - C#, VB.NET, C++, JavaScript" particularly the "XAML Popup sample".



来源:https://stackoverflow.com/questions/12371566/how-to-have-user-prompt-dialogs-in-windows-8-metro-apps

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