I have not problem adding tools to groups on the ribbon and to the the application menu left and right areas. However, I'm trying to do a remove on the application menu right area tools collection and it doesn't seem to do anything. I know that the tool is cloned so I tried to use the returned tool from the .Add, but that does not seem to work either.
Thanks for your help!
Here's the code I'm using to try to do the remove:
WorkItem.RootWorkItem.UIExtensionSites[UIExtensionSiteNames.AppMenuRight].Remove(btnProgramSetup);
It sounds like you are adding the tool to the application menu directly. To be able to remove a tool through the UIExtensionSite for the right area, you must also add it through the extension site. You are correct that the tool is cloned. So to remove the tool, you can use the following code:
UIExtensionSite toolAreaRight = WorkItem.RootWorkItem.UIExtensionSites[ UIExtensionConstants.AppMenuRight ];
foreach ( object item in toolAreaRight ){ ButtonTool tool = item as ButtonTool;
if ( tool == null ) continue;
if ( tool.Key != btnProgramSetup.Key ) continue;
toolAreaRight.Remove( tool ); break;}