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("请输入名称!", "提示");
  • 相关阅读:
    C#中抽象类和接口
    ArcGIS for Flex中引入google map作底图
    USB、UART、SPI等总线速率
    步步详解之第1节----ALTERA FPGA关于PLL的使用,帮你用光所有PLL
    FPGA笔试必会知识点2—FPGA器件
    FPGA笔试必会知识点1--数字电路基本知识
    (转)modelsim-win64-10.1c的安装
    基于FPGA的温度采集显示与报警
    基于FPGA的步进电机说明文档
    基于FPGA的直流电机
  • 原文地址:https://www.cnblogs.com/pzwsoft/p/4036393.html
Copyright © 2011-2022 走看看