我想在做一些工作时显示“加载”对话框。当我通过按钮单击事件触发作业时,它正在工作(主窗口显示为灰色,对话框显示为模态)。
XAML:
<Button Click="ClickButton" ... />
观点:
private void ClickButton(object sender, RoutedEventArgs e)
{
var dialog = this.Resources["MyDialog"];
this.ShowMetroDialogAsync(dialog as BaseMetroDialog);
... do the work
}
但是当我使用命令时
<Button Command="{Binding MyCommand}"
并在命令Execute method
中调用该对话框public async void Execute(object parameter)
{
MainWindow metroWindow = Application.Current.MainWindow as MainWindow;
var dialog = metroWindow.Resources["MyDialog"];
await this.ShowMetroDialogAsync(dialog as BaseMetroDialog);
... do the work
}
主窗口只显示灰色,没有显示对话框。