gpt4 book ai didi

c# - Mahapp ShowMessageAsync MvvM

转载 作者:太空宇宙 更新时间:2023-11-03 18:28:55 25 4
gpt4 key购买 nike

我使用 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;

希望对你有所帮助:)

关于c# - Mahapp ShowMessageAsync MvvM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26825250/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com