在WP 8.1 RT中以编程方式关闭MessageDialog
本文关键字:编程 方式关 MessageDialog WP RT | 更新日期: 2023-09-27 18:14:54
我想关闭并隐藏Windows Phone 8.1 RT中的MessageDialog
.我已经看到了呼叫.Cancel()
和.Close()
的多种解决方案,但没有在Windows Phone 8.1 RT上工作;
我如何关闭MessageDialog
从代码不与它交互?
用ContentDialog
代替MessageDialog
。ContentDialog有更多的自定义选项。您可以创建看起来像MessageDialog的ContentDialog而没有任何问题,并将其隐藏在代码中。
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
ShowContentDialog("cos");
await HideContentDialog();
}
ContentDialog _contentDialog;
private void ShowContentDialog(string s)
{
_contentDialog = new ContentDialog();
_contentDialog.Content = s;
_contentDialog.IsPrimaryButtonEnabled = true;
_contentDialog.PrimaryButtonText = "OK";
_contentDialog.Title = "title";
_contentDialog.ShowAsync();
}
private async Task HideContentDialog()
{
await Task.Delay(5000);
_contentDialog.Hide();
}