问题
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 TextBox
es) 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