November 11, 2005 .net

WPF: Handling Button.Click or defining a command?

If I’ve got an Avalon Button, e.g.

Should I give the button a name so I can handle the event (I would never put the event handler directly in the XAML) like this:

Or, should I define a custom command and invoke it like this:

Defining a command seems like overkill (you do some stuff in the static ctor and some other stuff in the instance ctor), but I like consistency, e.g. my main window’s menu will use commands.

Thoughts on the best practice here?