MahApps.Metro消息和进度连接

时间:2015-06-01 07:51:56

标签: c# mahapps.metro

我想用MahApps创建一个逻辑,如下所示:

ShowScreenCommand = new Command(async () =>
{
    var window = Application.Current.MainWindow as MetroWindow;
    if (await window.ShowMessageAsync("Are you sure to remove it?", "Removal", MessageDialogStyle.AffirmativeAndNegative) == MessageDialogResult.Affirmative)
    {
        await removePatientTask();
    }
});

private async Task removeTask()
{
    var window = Application.Current.MainWindow as MetroWindow;
    var controller = await window.ShowProgressAsync("Please wait...","Process message",false,new MetroDialogSettings());

    await Task.Delay(5000);
    await controller.CloseAsync();
}

问题是,“消息”和“进度”对话框之间存在差距。一个对话框隐藏,第二个显示。这看起来并不完美。

有没有办法消除这种差距?我的意思是,用另一个对话替换一个对话框?

1 个答案:

答案 0 :(得分:2)

尝试删除ShowMessageAsync方法的结束动画:

await window.ShowMessageAsync("Are you sure to remove it?", 
                              "Removal",
                              MessageDialogStyle.AffirmativeAndNegative,
                              new MetroDialogSettings 
                              { 
                                AnimateHide = false 
                              });

也许您还必须删除Progress的显示动画,它基本上是相同的代码,但将AnimateHide替换为AnimateShow