本文地址:https://blog.csdn.net/t163361/article/details/107997322
- 一键生成命令和请求
name是也给普通的宏
Name需要在Edit variables里设置如下图
先设置一个关联规则,然后选关联的变量


private SimpleCommand _$name$Command;
public SimpleCommand $Name$Command => _$name$Command;
private InteractionRequest _$name$Request;
public InteractionRequest $Name$Request => _$name$Request;
private void $Name$()
{
_$name$Command = new SimpleCommand(()=>
{
_$name$Request.Raise();
});
_$name$Command = new SimpleCommand($Name$);
_$name$Request.Raise();
}
- 一键生成属性
private $type$ $fieldName$;
public $type$ $propertyName$
{
get => this.$fieldName$;
set => Set(ref this.$fieldName$, value, "$propertyName$");
}
本文介绍在MVVM框架中如何通过简单的规则一键生成命令和属性,包括设置关联规则、创建命令实例和请求实例的过程。文章详细展示了如何使用宏定义来简化代码编写,适用于需要快速开发界面逻辑的场景。

2万+

被折叠的 条评论
为什么被折叠?



