In the new version of mvvmlight, dialogmessage is marked as obsolete and must be replaced by idialogservice. The specific usage of idialogservice is as follows:
First, implement idialogservice in the main form:
Public partial class mainwindow: window, idialogservice
Public System. Threading. Tasks. Task showerror (Exception error, String title, string buttontext, Action afterhidecallback) {Throw new notimplementedexception ();}
Public System. threading. tasks. task showerror (string message, String title, string buttontext, Action afterhidecallback) {Throw new notimplementedexception ();} public system. threading. tasks. task <bool> showmessage (string message, String title, string buttonconfirmtext, string buttoncanceltext, Action <bool> afterhidecallback) {Throw new notimplementedexception ();} public system. threading. tasks. task showmessage (string message, String title, string buttontext, Action afterhidecallback) {Throw new notimplementedexception ();} public system. threading. tasks. task showmessage (string message, String title) {// throw new notimplementedexception (); MessageBox. show (message, title); return NULL;} public system. threading. tasks. task showmessagebox (string message, String title) {// throw new notimplementedexception (); MessageBox. show (message, title); return NULL ;}
Then register idialogservice: Public idialogservice dialogservice {get {return servicelocator. current. getinstance <idialogservice> () ;}} is called dialogservice. showmessagebox ("enter a name! "," Prompt ");
[Original] use of idialogservice instead of dialogmessage in mvvmlight