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();
}

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

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

最佳答案 尝试删除ShowMessageAsync方法的结束动画:

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

也许你必须删除Progress的显示动画,它基本上是相同的代码,但是用AnimateShow替换AnimateHide.

点赞