Jos*_*gal 1 windows messagedialog windows-phone-8.1
如何在Windows Phone 8.1中以编程方式关闭"消息"对话框.我使用showAsync()创建了对话框.如果这不可能,这是创建具有以下属性的自定义消息对话框的最佳方法:
1. It can show test and hold buttons for user interaction.
2. It can be dismissed programmatically
3. Should block the view as a Normal MessageDialog do
Run Code Online (Sandbox Code Playgroud)
使用ContentDialog而不是MessageDialog.这也将允许自定义对话框,因此您不需要编写自定义控件,除非您想要做一些非常疯狂的事情.
在Windows上,MessageDialog是可取消的,但在Windows Phone上不可取消:
// Cancel the MessageDialog after 3 seconds on Windows
private async void Button_Click(object sender, RoutedEventArgs e)
{
MessageDialog md = new MessageDialog("Lorem ipsum dolor sit amet","Message Dialog Title");
var t = md.ShowAsync();
await Task.Delay(TimeSpan.FromSeconds(3));
// Ignored by the Windows Phone MessageDialog
t.Cancel();
}
Run Code Online (Sandbox Code Playgroud)
您可以在Windows Phone上使用类似代码取消ContentDialog.如果需要,您可以使用Visual Studio的ContentDialog模板创建自定义ContentDialog.
private async void Button_Click(object sender, RoutedEventArgs e)
{
ContentDialog cd = new ContentDialog();
cd.Title = "Content Dialog";
cd.PrimaryButtonText = "Close";
cd.Content = "Lorem ipsum dolor sit amet";
var t = cd.ShowAsync();
await Task.Delay(TimeSpan.FromSeconds(3));
t.Cancel();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1837 次 |
| 最近记录: |