This project has moved and is read-only. For the latest updates, please go here.

Closed event is fired before RoutedCommands

Aug 23, 2009 at 2:15 PM
Edited Aug 23, 2009 at 2:15 PM


I use an inlined TaskDialog with a command binding attached to a button of the TaskDialog, and now the problem: the closed event is fired before the command can do its magic, but I need this the other way round. Is there something you can do about this?



Aug 27, 2009 at 8:02 AM


The TaskDialog catches the ButtonBase.ClickEvent globally, by letting it bubble up. Unfortunately, the click event is fired before the routed command. I can think of two solutions (I haven't tried any of them, though):

  1. Inherit from Button and override OnClick(), where you'll raise the Click event after invoking the command (I suggest peeking at the base implementation with Reflector).
  2. Subscript to the button's Click event and mark it as Handled, then close the dialog yourself.

Hope this helps,