views:

22

answers:

1

At a conceptual level (not platform/framework specific), how should components like toolbars and menus (and the commands they contain) be implemented in a desktop application that uses the MVC pattern, with minimum coupling & maximum code reuse?

+1  A: 

Generally, commands are bound to menu items, toolbar buttons etc. would expose following information to controls:

  • Executing method
  • Enabled/Disabled flag
  • (Optional) Visible/Hidden flag
  • (Optional) Icon
  • (Optional) Text
  • (Optional) Description
  • Event notified about command state is changed

If you prefer to use MVC pattern, not MVVM, you probably being hard to determine where command logic would be placed. You may expose these information via model, or you may place corresponding code in controller.

If you use component-based UI, like .NET WPF/WindowsForms/Silverlight etc., you probably may create interface for the command that exposes all listed properties, and create custom controls inherited from MenuItem, ToolbarButton etc. that handles information from such interface.

STO