码迷,mamicode.com
首页 > 其他好文 > 详细

[原创]MvvmLight中用IDialogService替代DialogMessage的用法

时间:2014-10-20 08:41:12      阅读:377      评论:0      收藏:0      [点我收藏+]

标签:io   ar   使用   sp   div   on   art   cti   log   

在新版的MvvmLight中,DialogMessage被标注为已过时,需要用IDialogService来替代,IDialogService的具体用法如下:

先在主窗体中实现IDialogService :

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;         }
然后在其它窗体中登记IDialogService:
        public IDialogService DialogService
        {
             get
            {
                return ServiceLocator.Current.GetInstance<IDialogService>();
            }
        }
使用时即为:
DialogService.ShowMessageBox("请输入名称!", "提示");

[原创]MvvmLight中用IDialogService替代DialogMessage的用法

标签:io   ar   使用   sp   div   on   art   cti   log   

原文地址:http://www.cnblogs.com/pzwsoft/p/4036393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!