Hi, I have a ribbon that contains a MenuTool with a ButtonType of 'Segmented.' This menutool has a command set "delete" but *not* added to the Items collection, and a second command "delete all" that is added.
In the gui this makes it so that there is a delete button, and then if the user wants they can click the little down arrow and select delete all. The commands themselves work great. The problem though is that the sensitivity of the delete button does not alawys update right away.
The delete command will become enabled, but will still be grayed out in the ribbon. If I click anything like the button, the down arrow, or switch to a different tab and then switch back, only then will it become enabled.
I have noticed that when I set the ICommand on the MenuTool, it is not attaching itself to the CanExecuteChanged property of the ICommand (CanExecuteChanged continues to be null). Is there something I'm missing other than CanExecuteChanged that I need to hook up to make the MenuTool update itself when the command becomes enabled?
This is with version 9.2.20092.2032 which is I know is not the latest version but we can't update to the current SR just yet (hopefully soon).
I'll submit an issue for this. The command used by the elements within the menu tool is actually a different command so that the menu can also raise its Click event as well. You should be able to workaround this issue you are reporting for now by invoking the CommandManager.InvalidateRequerySuggested method. The reason this fixes itself is that the wpf framework will invoke this method at various times like when the mouse is pressed down or a key is pressed.
Note you should be aware that command sources don't unhook from the command's CanExecuteChanged so you have to be careful about how you implement your ICommand or you will create a memory leak. This is discussed/mentioned in several places on the web:
http://joshsmithonwpf.wordpress.com/2008/03/18/understanding-routed-commands/#comment-10430
http://msdn.microsoft.com/en-us/library/ee712881.aspx#CommandMemoryIssues
http://compositewpf.codeplex.com/WorkItem/View.aspx?WorkItemId=4065