Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming commands in WPF

Not having english as my primary language, I often question grammar when naming methodes and properties.

I use NextCommand as name for my command, NextCommandExecuted for the execution method and CanNextCommand for the status.

Does this make sense, or is there a more correct naming convention I should use?

like image 912
rozon Avatar asked May 26 '11 06:05

rozon


People also ask

Can you Execute in WPF?

The Execute method contains the command's functionality. This is run automatically when the user correctly interacts with a control, or presses a keyboard combination, that is linked to the command. CanExecute. The CanExecute method is called by WPF to determine whether or not the command is currently available.

What is routed command in WPF?

WPF-routed commands give you a specific mechanism for hooking up UI controls such as toolbar buttons and menu items to handlers without introducing a lot of tight coupling and repetitive code into your application.

What are commands in WPF?

Commands in WPF are created by implementing the ICommand interface. ICommand exposes two methods, Execute, and CanExecute, and an event, CanExecuteChanged. Execute performs the actions that are associated with the command. CanExecute determines whether the command can execute on the current command target.


1 Answers

In your suggested names NextCommandExecuted sounds/seems like the command has been executed or it has completed its execution which sounds a bit incorrect to me.

I would prefer

NextCommand

NextCommandExecute

and

CanNextCommandExecute

like image 165
Haris Hasan Avatar answered Oct 01 '22 21:10

Haris Hasan