I'm attempting to add a ButtonTool to the quick access toolbar but nothing is showing up. What I would really like to do is add the ButtonTool to the ribbon's ToolsNotInRibbon collection so that the tool only shows up in the QAT. I've attached a sample project that illustrates my problem. The relevant code is in the MainWindowView.xaml.cs in the GetRibbonTabItem to show the ToolsNotInRibbon problem and the HostRibbon_OnLoaded that shows the issue with it not showing when added as a normal ButtonTool.QuickAccess.zip
Andrew,
Wow, I honestly thought I had tried that! Thanks so much for your help it is working just as I wanted.
Hello Collin,
I have revisited the QuickAccess sample project that you have provided, now targeting version 17.2.20172.2029 and commenting out all of the code in the HostRibbon_OnLoaded method to try to get the QAT creation to happen purely in the GetRibbonTabItem method of the MainWindowView.xaml.cs file.
I was able to achieve this by uncommenting the code that you had provided and then constructing a QatPlaceholderTool within a Dispatcher.BeginInvoke action. In doing so, I am able to see the tool only show up in the QAT. If the Dispatcher.BeginInvoke action is not present, it appears that I am personally hitting that timing issue again where it doesn't seem that the tool is actually "registered" with the ribbon just yet, and so we throw an exception.
I am attaching the modified version of the sample project to demonstrate. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
7750.QuickAccess.zip
While this approach works it requires too intimate knowledge of tab, ribbon group and button layout to be useful in the long run. The HostRibbon_OnLoaded method was only present for illustration purposes and I was hoping to make it go away completely. I wanted to be able to handle all the tab, ribbon group and button creation in the GetRibbonTabItem method. The original project contained the call to ToolsNotInRibbon.Add (commented out) in that method that illustrated the problem I'm trying to overcome. I tried surrounding the call with the BeginInvoke block with no success. Is it not possible to make this call in this situation? Also, I did not see the crash you describe, version 17.2.20172.2029. We are planning to update soon.
I have been investigating the sample project you have provided, and it appears that the reason that you are unable to add your ButtonTool to the QuickAccessToolbar in your sample is due to a timing issue. Currently, on my end, the sample you have provided actually crashes as a result of trying to add your QatPlaceholderTool in the HostRibbon_OnLoaded event, but if I surround the code in this event in a Dispatcher.BeginInvoke action, everything is working normally. I am unsure if you are currently seeing this crash or not.
With the above said, you should be able to add the ButtonTool to the ToolsNotInRibbon collection of the XamRibbon and still have them show up in the QAT. I have modified the sample project that you have sent me such that this is now the case and am attaching it here.
It is also worth noting that it appears that you are using the version-free assemblies and so I cannot be sure which version you are actually using in this case. My tests were made against version 18.1.20181.255 in Infragistics for WPF 2018.1.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
2626.QuickAccess.zip