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


    在新版的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("请输入名称!", "提示");
  • 相关阅读:
    Delphi下的WinSock编程
    基于Delphi使用API实现Sock通讯
    delphi7与XE的变量与函数的改变
    Delphi7·ProgressBar控件
    delphi 进度条
    delphi带包编译详解(build with runtime package)
    TList 的 quicksort 算法研究和使用。
    Delphi7升级到Delphi 2010、Delphi XE、Delphi XE2总结
    Delphi编译错误代码翻译表
    Firebird(火鸟)数据库 v3.0.3.32900官方版
  • 原文地址:https://www.cnblogs.com/pzwsoft/p/4036393.html
Copyright © 2020-2023  润新知