When I first started using .NET (as of 2.0) it was a big step back coming from Delphi’s TActionList and TAction to a framework with no built in commanding system (WinForms). WPF certainly turned that around!
Nowadays I use a custom DelegateCommand class (like the one found in MVVM Light) rather than the built in commands, but the fact that I can do that is a testament to how nicely put together the command system is. In one project I even derived my own command type and added an “IsAvailable” property so I could hide the buttons/links/menu items altogether if the command made no sense (rather than just disabling) and it worked a treat. Matt From: Greg Keogh Sent: Wednesday, October 27, 2010 10:34 AM To: 'ozWPF' Subject: In praise of commands Just to prove to Stephen that I have not been replaced by a Borg (who programs and upgrades those guys anyway?) I was a bit sceptical at first about the WPF Command routing system, but now I’m impressed by how effective and easy it is to use. Just setting the Command property of menus and buttons to a RoutedUICommand will let that command event bubble up as far as you want (to the app window in my case). There are lots of pre-supplied commands like ApplicatonCommands.XXX etc and it’s trivial to create another set of your own commands. Calling CommandBindings.Add( ) adds the pairs of handlers for each command in a way that reminds me of the old MFC technique. It’s nice that the pre-supplied command text is localised and can be used as the control text. So overall, the bubbling of commands really cuts down on the amount of wire-up code needed and you can put all the command handling code in convenient place(s) in your choice. Greg -------------------------------------------------------------------------------- _______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
_______________________________________________ ozwpf mailing list [email protected] http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
