简体   繁体   English

如何在Windows Phone 8.1中显示模式窗体

[英]How to display a Modal form in Windows Phone 8.1

I have a Windows 8.1 WinRT app. 我有一个Windows 8.1 WinRT应用程序。 I want to have a XAML control in which i can have xaml controls like a button, textblock, listbox, etc. 我想要一个XAML控件,其中可以有xaml控件,例如按钮,文本块,列表框等。

I want to be able to load this XAML control in any page from the app. 我希望能够在应用程序的任何页面中加载此XAML控件。 But i want it to appear as a modal, on top of the current page over a black overlay. 但我希望它以模态形式出现在当前页面顶部的黑色覆盖层上。

How can i load a Xaml control on top of the current page? 如何在当前页面顶部加载Xaml控件? Is there a way ot interact from this overlay with the other controls in the current page? 从此叠加层是否可以与当前页面中的其他控件进行交互?

Example: while on a page, i want to open the modal and tap a button which will fill a form in the current page with test data. 示例:在页面上时,我想打开模式并点击一个按钮,该按钮将在当前页面中用测试数据填充表格。

You can host your controls in a ContentDialog . 您可以将控件托管在ContentDialog中 Visual Studio has a ContentDialog template which you can use to create the dialog like you would a UserControl. Visual Studio有一个ContentDialog模板,您可以像使用UserControl一样使用它来创建对话框。 You can then launch it modally on top of any page: 然后,您可以在任何页面顶部以模态方式启动它:

private async void Button_Click(object sender, RoutedEventArgs e)
{
    ContentDialog1 cd = new ContentDialog1();
    cd.TestData = "Lorem ipsum";
    await cd.ShowAsync();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM