0

I know there where many questions regarding how to open a MessageBox in UWP, but how do I open a MessageBox in MVVM?

After the User clicks A <Button> it fires a Command Command="{Binding FireComand}" in my VM it is handled like usual. In my case it adds an object to an ObservableCollection.

But I want my Users to get Feedback, that their Action worked/or not.

Is there an easy way to show a simple MessageBox "Done!" surrounded by a black Rectangle which closes after 2 sec?

EDIT: What I want is something like this

enter image description here

Daniel Maurer
  • 156
  • 1
  • 15

1 Answers1

0

You can dismiss a MessageDialog by cancelling the task created when calling its ShowAsync method, take a look at Programmatically dismiss a MessageDialog

Regarding MVVM, I abstracted dialogs into a service that I use in my ViewModels, take a look at https://github.com/igorkulman/Kulman.UWP/blob/master/Kulman.UWP/Services/DialogService.cs

Igor Kulman
  • 16,211
  • 10
  • 57
  • 118
  • Thank you! I will take a look in there. So DispatcherTimer dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromSeconds(5); dt.Tick += dt_Tick; dt.Start(); } -> This Gets the Countdown, but how do I Close it from my VM? Sorry to bother you so much. – Daniel Maurer May 23 '17 at 08:43
  • Another question: How do I implement your Code? – Daniel Maurer May 23 '17 at 21:08