Breaking handler chain

You can abort the command chain by setting the CancelPropagation property to true.

  Program.Commands.Add(typeof(YourCommand), OnYourCommand);
  Program.Commands.Add(typeof(YourCommand), OnYourCommand2);

  Program.Commands.Invoke(new YourCommand());

  public bool OnYourCommand(object source, Command command)
  {
    command.CancelPropagation = true;
    return true;
  }

  public bool OnYourCommand2(object source, Command command)
  {
    //will never be invoked.
  }


You can also determine which handlers are allowed to break the chain, check the PropagationCancelled in the CommandManager.

Last edited Aug 25, 2008 at 5:01 PM by jgauffin, version 3

Comments

No comments yet.