[原创]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("请输入名称!", "提示");

时间: 2024-12-19 13:49:40

[原创]MvvmLight中用IDialogService替代DialogMessage的用法的相关文章

Autoit中用PrintWindow替代ScreenCapture函数实现截图

想截取躲在后面的窗体或控件,找到了PrintWindow函数,幸运的是Autoit3也对此进行了封装以方便使用. 于是乎,将帮助文件里的_WinAPI_PrintWindow()实例改写了一下,以替代ScreenCapture系列函数: #include <WinAPIGdi.au3> #include <Clipboard.au3> HotKeySet("q", "exam") While 1 Sleep(100) WEnd Func ex

cocos2dx中替代goto的用法:do{}while(0)和CC_BREAK_IF

我们时常会调用某个函数来创建一个对象,但由于内存不足或其他异常情况发生时对象可能会创建失败,创建失败我们就要结束当前程序转到错误处理地方去处理错误或释放已生成的对象. int* p1 = new int; CCObject* o1 = fun1(); if(!o1) goto catchcode; CCObject* o2 = fun2(); if(!o2) goto catchcode; //如果代码都执行成功 delete p; p = NULL; //如果o1 o2有发生错误 catchc

RecyclerView(替代ListView)用法介绍

在build.gradle文件添加下面代码 compile 'com.android.support:cardview-v7:21.0.3' compile 'com.android.support:recyclerview-v7:21.0.3' item类型相同的情况 布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="

nodejs中用cnpm替代npm来安装package

一条命令就搞定了 npm install -g cnpm --registry=http://r.cnpmjs.org 以后安装package,就可以用cnpm ...来搞定了,cnpm由淘宝团队维护. 参考: http://cnpmjs.org/

xUtils中用DbUtils,ViewUtils的用法

一.有关xUtils的简介 xUtils 包含了很多实用的android工具.xUtils 最初源于Afinal框架,进行了大量重构,使得xUtils支持大文件上传,更全面的http请求协议支持(10种谓词),拥有更加灵活的ORM,更多的事件注解支持且不受混淆影响...xUitls最低兼容android 2.2 (api level 8) 二.总共包含4个功能模块: (1)DbUtils模块: android中的orm框架,一行代码就可以进行增删改查:支持事务,默认关闭:可通过注解自定义表名,列

C# 中用 Sqlparameter 的几种用法

新建一个表: create table abc (     id int IDENTITY(1,1) NOT NULL,    name nvarchar(100) ,    sex  nvarchar(10) ) insert into abc values('asf','男') insert into abc values('ai','女') 创建表格完成. 新建一个存储过程: create procedure selbyid(@id int,@thename nvarchar(100) o

awk简单用法

awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各种分析处理. awk有3个不同版本: awk.nawk和gawk,未作特别说明,一般指gawk,gawk 是 AWK 的 GNU 版本. 1.域分割符 awk 在没有使用-F 指定分割符的时候.默认以空格为分割符. 域分割 $0代表文本内容全文显示 $1 代表分割第一个域 $2 代表分割第二个域 依

Bitbucket - 用git 用法

核心流程: 从远端中心repo那里Git clone 到本地,再在本地开发(add, commit), 通常会利用branch管理,如果觉得code 没问题了,就push到远端的中心repo上.这里中心的repo 就是 bitbucket上的repo. git 之后 不需要 减号- 1. git  clone https的path 把repo下载到本地 2. git status 查看哪些文件修改了. 如果提交前,想看看具体那些文件发生变化,可以通过git-diff来查看.git diff 与

awk的用法

前言 awk是一个模式扫描及处理语言.既然是一门语言,那么它就拥有类似于其他编程语言.所以同学们,要学好awk,必须要有shell或其他语言的编程基础,如果你没有编程基础,那么先去建立吧. 基础语法 1.awk | -F field-separator| `cmd` input file awk -F : `cmd` input file 2.将awk命令插入一个文件,并使awk程序可以执行,然后用awk命令解释器作为脚本首行. 3.将所有awk命令插入一个单独文件   awk -f awk-s