我用MVVM模式创建了最简单的WPF项目。如何从viewModel调用ShowMessageAsync
?
if (DisciplineText!="")
{
Disciplines.Add(new Discipline(){ChairID = SelectedChair.ChairID,SemesterID = SelectedSemester.SemesterID,Discipline1 = DisciplineText});
Context.SaveChanges();
}
else
{
// ShowMessageAsync????????
}
最佳答案
MetroWindow metroWindow = Application.Current.MainWindow as MetroWindow;
metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented; // set the theme
await MetroWindow.ShowMessageAsync("Title", "Message");
您需要使用:
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
希望对您有所帮助:)