Linking commands to a context menu

Topics: CAB & Smart Client Software Factory
Apr 19, 2006 at 11:14 PM
originally posted by: Dave_Bates

I am trying to develop a screen similar to outlook. Where I have two tree view controls in the left pane, one representing the items and one for favourites. These tree views list the same type of business objects. I also have a menu, a toolbar and a context menu that is popped up for each tree view. I’ve linked a menu item, toolbar button and a context menu item to a command for a “Properties” command. On selection of one of the items in the tree views I can handle the status the command and therefore enable/disable the relevant attached UI invokers.

What is the best way to achieve having a context item (when right clicking a tree view node). The program needs to enable/disable commands for the selected context item but not do a “full” select of that item. I have hooked into the context menu closed event to handle re-setting the status of the command, but it seems as though the context menu closed event fires before it gets to the command handler. So basically when the context menu is closed, I will potentially disable the command before the command handler gets called. The command event never fires because by that time the command is disabled.

What would be the recommended approach for dealing with this “context/partial selection” situation?