【问题标题】:Windows Phone 8.1 - ContentDialog never gets hiddenWindows Phone 8.1 - ContentDialog 永远不会被隐藏
【发布时间】:2015-03-02 16:36:15
【问题描述】:

在我的 Windows Phone 8.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();

所以,对话框显示没有任何问题,但它永远不会被隐藏。

有什么想法吗?

谢谢。

【问题讨论】:

  • 您的“内容”对话框中是否有应隐藏的内容?因为我认为您的程序永远不会到达contentDialog.Hide();,因为它正在等待对话框关闭。

标签: c# windows-runtime windows-phone windows-phone-8.1


【解决方案1】:

尝试使用这个:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多