[Designer(typeof(MyCustomActivityDesigner))]
public sealed class MyCustomActivity : AsyncCodeActivity
{
public MyCustomActivity()
{
AddSpecificParameter = new DelegateCommand(AddParameter);
}
public DelegateCommand AddSpecificParameter { get; set; }
public void AddParameter()
{
//add value to an obervable collection
}
}
中继命令实现:
public class DelegateCommand :ICommand
{
//Parameterless constructor needed as windows workflow serialises it
public DelegateCommand()
{ }
private readonly Action _action;
public DelegateCommand(Action action)
{
_action = action;
}
public void Execute(object parameter)
{
_action();
}
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
}