MahApps.Metro 消息和进度连接

4

我想使用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();
}

问题在于,消息对话框和进度对话框之间存在一个间隙。一个对话框隐藏,另一个对话框显示,这看起来并不完美。
有没有办法消除这个间隙?我的意思是,用另一个对话框替换一个对话框?

为什么消息会改变语言? - ta.speot.is
抱歉 :) 我忘记改了 :) - Tomasz
1个回答

2
尝试移除 ShowMessageAsync 方法的关闭动画:
await window.ShowMessageAsync("Are you sure to remove it?", 
                              "Removal",
                              MessageDialogStyle.AffirmativeAndNegative,
                              new MetroDialogSettings 
                              { 
                                AnimateHide = false 
                              });

也许您还需要移除进度条的显示动画,这基本上是相同的代码,只需将 AnimateHide 替换为 AnimateShow 即可。

之后,为了更进一步,您可以实现一个“CustomDialog”,并将这两个对话框合并成一个。 - Gimly

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接