我正在使用两个主题,一个会在WPF
中使用 MahApps MessageDialog 询问用户问题,
另一个我想在下面的代码中隐藏MessageDialog,如何在HideMessageDialog()
中隐藏MessageDialog?
我正在做一些需要中断问题的事情,同时保持主窗口打开。所以我需要一种方法来在对话框真正显示后隐藏对话框。
public void Execute()
{
Task showAsk = new Task(ShowAskingDialog);
Task hideAsk = new Task(HideAskingByCode);
showAsk.Start();
hideAsk.Start();
}
public async void ShowAskingDialog()
{
Thread.Sleep(3000);
this.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
var msgbox_settings = new MetroDialogSettings {
AffirmativeButtonText = "I know", NegativeButtonText = "I don't know" };
// puase at asking MessaageDialog
var isKnow = await this.ShowMessageAsync(
"Question", "Do you know WPF?",
MessageDialogStyle.AffirmativeAndNegative, msgbox_settings);
}
public void HideAskingByCode()
{
Thread.Sleep(5000);
//How to Hide the MessageDialog by code, not by user click Button?
HideMessageDialog();
}
MessageDialog将显示如下,嵌入在主窗口中:
答案 0 :(得分:0)