Hi,
I am looking for a way to prevent certain tools and Ribbon Groups from being added to the QAT. I thought I might attach to the Cloned event and then remove the clone from the QAT, but this does not work for Groups. What is the best way to do this?
Thanks
Unfortunately there is a public property to prevent a RibbonGroup/Tool from being added to the qat. You can prevent a tool from being added to the QAT by deriving from it, reimplementing the IRibbonTool interface and returning a derived RibbonToolProxy that returns false from its CanAddToQat. This is normally done if you have a tool type that shouldn't be put into the qat. However there is no mechanism for preventing a group from being added to the qat. The Microsoft Office UI Guidelines require that a tool or group must provide the option to add that item to the QAT.
I am having the same issue and was going to try the solution above, but RibbonToolProxy has an internal default constructor and thus can not be inherited from. Are there any other approaches for this?
Currently I am implementing the Recent Files part of our Application Menu. I am adding MenuTools to it and right now you can right click on any of the recent items and add them to the QAT. This is silly, and is not allowed in Microsoft Office either and I am trying to figure out how to prevent this.
Is there perhaps a tool other than MenuTool that is intended for use in the recent files area? One which supports using _ for underlined shortcuts (as MenuTool does) but also supports pinning as in Office 2007?
slayn said:Are there any other approaches for this?
slayn said: I am adding MenuTools to it and right now you can right click on any of the recent items and add them to the QAT. This is silly, and is not allowed in Microsoft Office either and I am trying to figure out how to prevent this.
slayn said:Is there perhaps a tool other than MenuTool that is intended for use in the recent files area? One which supports using _ for underlined shortcuts (as MenuTool does) but also supports pinning as in Office 2007?
I changed my implementation to inherit from MenuToolProxy instead of RibbonToolProxy<MenuToolNonQat> and now everything seems to work.
I created these classes:
public class MenuToolNonQat : MenuTool, IRibbonTool { public class RibbonToolProxyNonQat : RibbonToolProxy<MenuToolNonQat> { override public bool CanAddToQat { get { return false; } } };
public RibbonToolProxy ToolProxy { get { return new RibbonToolProxyNonQat(); } } }
And I'm adding them to the recent items instead of MenuTools. They show up in the Recent Items list, and have correct behavior in that they can not be added to the QAT. However, when I click on them nothing happens. If I switch back to MenuTool it works, so there must be something wrong with my class above. Are there other pieces I have to implement besides CanAddToQat?
Also, I tried the 2nd approach as well of using ToolMenuItem. But when I do that, I get crashes in PresentationFramework.dll when I try to show the application menu. a call to System.Windows.Controls.Primitives.OnWindowResize() fails because _positionInfo is null.