About the application of lambda and relayCommand
来源:互联网 发布:java字符串转换整形 编辑:程序博客网 时间:2024/06/04 18:48
public RelayCommand<TextEditor> SaveCommand
{
get
{
?? 代表这个返回的_saveCommand为false时,就new一个新对象返回。
return _saveCommand
?? (_saveCommand = new RelayCommand<TextEditor>(
editor =>
{
try
{
// Can't add Encoding when save, it's wired, but it's the fact. Otherwise some wired character will appear at the beginning of line 1
File.WriteAllText(Case.CasePath, editor.Text);
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
return;
}
MessageBox.Show("Case " + Case.CaseName + " saved.");
}, (x) => !this.CaseIsRunning));
}
}
editor => 和(x) =>这两个lambda函数作为参数在RelayCommand的构造函数中。
如_saveCommand=new RelayCommand<TextEditor>(void A{},bool B{});当B为真时,A函数才执行。
这种语法是在RelayCommand的构造函数中定义的,A是excute()方法,后面是CanExcute()后者返回一个bool类型,当返回值为ture是excute才会执行。
{
get
{
?? 代表这个返回的_saveCommand为false时,就new一个新对象返回。
return _saveCommand
?? (_saveCommand = new RelayCommand<TextEditor>(
editor =>
{
try
{
// Can't add Encoding when save, it's wired, but it's the fact. Otherwise some wired character will appear at the beginning of line 1
File.WriteAllText(Case.CasePath, editor.Text);
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
return;
}
MessageBox.Show("Case " + Case.CaseName + " saved.");
}, (x) => !this.CaseIsRunning));
}
}
editor => 和(x) =>这两个lambda函数作为参数在RelayCommand的构造函数中。
如_saveCommand=new RelayCommand<TextEditor>(void A{},bool B{});当B为真时,A函数才执行。
这种语法是在RelayCommand的构造函数中定义的,A是excute()方法,后面是CanExcute()后者返回一个bool类型,当返回值为ture是excute才会执行。
阅读全文
0 0
- About the application of lambda and relayCommand
- About the Usage of fseek and ftell
- About the pause of C++ win32 console application
- The introduction and application of PLC
- Information About The Space of MFC and C#,ASP.NET
- About the Height and Width property of DisplayObject
- The Details About Syntax of gcc as and ld
- the easy article about '__init__ 'and 'self' of class
- About the Caching Application Block
- State of the Lambda
- All about TAF - 10g&11g :Configuration of TAF(Transparent Application Failover) and Load Balancing
- Windows Phone 8: Evolution of the Runtime and Application Compatibility
- P1.The application of function ord() and chr()
- How to get Version of the application and API version
- About the Lambda FAQ(关于Lambda的问答集)
- the application of pointer
- About the type of backup!
- About the address of variable
- scala创建动态二维数组Array[ArrayBuffer[]]三种写法
- Android 中的消息传递-广播机制
- SSM(十) 项目重构-互联网项目的Maven结构
- JS简单实现点击复制链接的方法
- 《Python编程:从入门到实践》2-9章 笔记
- About the application of lambda and relayCommand
- Android 6.0 ProgressBar 自定义动画不显示问题
- ubuntu16.04+cuda8.0+cudnn5.1+caffe 安装(基于独立主机&集成显卡>X1080Ti)
- angular中ng-mouseenter、ng-mouseleave的时间差导致dom闪屏问题(timeout可缓解)
- ViewStub用法
- SSM(十一) 基于dubbo的分布式架构
- java中Calendar.DAY_OF_WEEK需要减一的原因
- vue2的全局变量的设置
- UidGenerator:百度出品的基于 Snowflake 算法的唯一 ID 生成器