C# Windows Phone 8.1-内容对话框永远不会隐藏

C# Windows Phone 8.1-内容对话框永远不会隐藏,c#,windows-runtime,windows-phone,windows-phone-8.1,C#,Windows Runtime,Windows Phone,Windows Phone 8.1,在我的WindowsPhone8.1应用程序中,我使用ContentDialog来显示一些数据。当我调用contentDialog.ShowAsync()时;它按预期显示,但当我试图隐藏它时,对话框一直在屏幕上 我的代码如下: StackPanel stackPanel = new StackPanel(); ProgressBar progressBarDialog = new ProgressBar(); progressBarDialog.Width = 300; progressBarD

在我的WindowsPhone8.1应用程序中,我使用ContentDialog来显示一些数据。当我调用contentDialog.ShowAsync()时;它按预期显示,但当我试图隐藏它时,对话框一直在屏幕上

我的代码如下:

StackPanel stackPanel = new StackPanel();
ProgressBar progressBarDialog = new ProgressBar();
progressBarDialog.Width = 300;
progressBarDialog.Height = 10;
progressBarDialog.IsIndeterminate = true;

TextBlock textBlockDialog = new TextBlock();
textBlockDialog.Text = "Loading...";
textBlockDialog.FontSize = 17;
textBlockDialog.Foreground = new SolidColorBrush(Colors.White);
textBlockDialog.HorizontalAlignment = HorizontalAlignment.Center;

stackPanel.Children.Add(progressBarDialog);
stackPanel.Children.Add(textBlockDialog);

ContentDialog contentDialog = new ContentDialog();
contentDialog.Content = stackPanel;
SolidColorBrush color = new SolidColorBrush(Colors.Black);
color.Opacity = 0.7;
contentDialog.Background = color;
contentDialog.Margin = new Thickness(0, 250, 0, 0);

await contentDialog.ShowAsync();
//Perform long operations
contentDialog.Hide();
因此,对话框显示时没有任何问题,但从不隐藏

有什么想法吗

谢谢。

尝试使用以下方法:

var t =  contentDialog.ShowAsync();
t.Cancel();

您的内容对话框中是否有应该隐藏它的内容?因为我认为您的程序永远无法访问
contentDialog.Hide()正在等待对话框关闭。