J'ai du mal à implémenter IDialogService défini dans l'assembly GalaSoft.MvvmLight. Vous pouvez obtenir ce à partir du paquet NuGet MvvmLightLibsComment implémenter IDialogService
public interface IDialogService
{
Task ShowError(string message, string title, string buttonText, Action afterHideCallback);
Task ShowError(Exception error, string title, string buttonText, Action afterHideCallback);
Task ShowMessage(string message, string title);
Task ShowMessage(string message, string title, string buttonText, Action afterHideCallback);
Task<bool> ShowMessage(string message, string title, string buttonConfirmText, string buttonCancelText, Action<bool> afterHideCallback);
Task ShowMessageBox(string message, string title);
}
Je suis en train de mettre en œuvre la première méthode comme si
public Task ShowError(Exception error, string title, string buttonText, Action afterHideCallback)
{
//var result = MessageBox.Show("");
return Dispatcher.Invoke(() => MessageBox.Show("whatever"));
//return Dispatcher.BeginInvoke(delegate() { MessageBox.Show("your stuff"); });
//var dg = new Action(() => { MessageBox.Show("", ""); });
//return Dispatcher.CurrentDispatcher.BeginInvoke(dg);
}
Comment puis-je utiliser Messagebox.Show cette méthode async pour WPF? S'il vous plaît aider.
J'essaie de voir qui fonctionne, mais jusqu'ici pas de chance. Quelqu'un peut-il m'aider s'il vous plaît?
Vous voulez implémenter ShowError en tant que méthode asynchrone? – Joe
oui, messagebo dans une méthode asynchrone – VivekDev