wpf prism 自定义委托命令DelegateCommand

//构造函数
public MainWindowViewModel()
{  
    EditCommand = new DelegateCommand(_editCommand);
}
//命令声明一
public DelegateCommand EditCommand { get; set; }
//构造函数中实例化委托
void _editCommand() {
    MessageBox.Show("EditCommand ");
}



//命令生命方式二
private DelegateCommand _testCmd;
public DelegateCommand TestCmd =>
    _testCmd ?? (_testCmd = new DelegateCommand(ExecuteTestCmd));
void ExecuteTestCmd()
{
    MessageBox.Show("ExecuteTestCmd");
}


posted @ 2023-10-30 13:04  窦戈  阅读(253)  评论(0编辑  收藏  举报