zoukankan      html  css  js  c++  java
  • [原创]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("请输入名称!", "提示");
  • 相关阅读:
    OpenOffice 在 Linux 下安装使用
    LINUX环境使用rpm命令安装gcc
    用shell脚本执行mysql脚本
    CentOS 7下用firewall-cmd控制端口与端口转发详解(转载)
    Hive字段中文注释乱码解决办法
    真正从零开始,TensorFlow详细安装入门图文教程!
    九、Oracle SQL(优化专题&分表分区)
    八、Oracle SQL(聚合函数&标量函数)
    七、Oracle SQL(Oracle 定时任务基础)
    六、Oracle SQL(游标&RECORD&存过、游标、RECORD整合)
  • 原文地址:https://www.cnblogs.com/pzwsoft/p/4036393.html
Copyright © 2011-2022 走看看