复合命令执行条件
约 111 字小于 1 分钟
PrismC#MVVMWPF
2025-06-10
var compositeCommand = new CompositeCommand(true);CompositeCommand 的构造函数可以传入一个 bool 类型的参数,表示是否需要所有子命令都处于活动状态时才被执行。默认值为 false,表示只要有一个子命令处于活动状态,就会被执行。
compositeCommand.RegisterCommand(subCommand1);
compositeCommand.RegisterCommand(subCommand2);
subCommand1.IsActive = true;
subCommand2.IsActive = false;
compositeCommand.Execute(); // subCommand1 will be executed