We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to update QAT ribbon buttons by source code at run time

I tried to remove all ribbon buttons from QAT and add some new ribbon buttons into QAT, but it didn't work. The following is my source code:

void UpdateQAT ()
{
            // Remove all ribbon buttons from QAT
            this.quickAccessToolbar.Items.Clear();

            // Create a new ribbon button instance
            RibbonButton RibbonButton = new RibbonButton();
            RibbonButton.SmallIcon = new BitmapImage(new Uri("/Resources/Redo16.png", UriKind.Relative));
            RibbonButton.SizeForm = SizeForm.ExtraSmall;
            // Create a new QuickAccessToolBar object
            QuickAccessToolBar QAT = new QuickAccessToolBar();
            // Add the new ribbon button into the QAT's items
            QAT.Items.Add(RibbonButton);
            // Let the QAT control reference the new QAT object
            this.qat = QAT;
}
Is that a right way to do that? Otherwise, how to do it?

Another question, I added a few ribbon buttons in a group into QAT at once, there would be a new button like splitbutton in the QAT, I clicked the new splitbutton in QAT, and hit one item in the dropdown list, nothing happened, it looked like the mouse click event was not been triggered.  Is it a bug? Otherwise how to triger the mouse click event?





10 Replies

NT Nick Tang May 4, 2016 12:51 AM UTC

I am using the latest syncfusion dll, the dll version is 14.1451.0.41


VR Venkateshwaran Ramdoss Syncfusion Team May 4, 2016 01:24 PM UTC

Hi Nick,

We have created a sample by using your code snippet. But the reported issues has not reproduced. In this sample, We have added the SplitButton contains RibbonButtons and click event get fired for the RibbonButton. Please download the sample from the below link.

Sample: QATSample

Could you please provide more details about your query by modifying the sample or providing replication steps to reproduce the issue.

Regards,
Venakteshwaran V.R.



NT Nick Tang May 5, 2016 03:57 AM UTC

Thanks for your demo. UpdateQAT worked well. You misunderstood my words about the mouse click event wasn't triggered, I have a demo for you, please following the steps to reproduce this issue:
1. Right click the text body of the ribbonbar 'TestRibbonBar'
2. Hit the menu item 'Add to Quick Access Toolbar'
3. A New split button is been added in the QAT, click the split button
4. Hit 'TestButton1' item in the drop down list

Actual result:
Nothing happened
Expected result:
A message dialog should pop up, said "QAT Ribbon Button 1 clicked"





Attachment: QATSample__MouseClickEventIssue_d99dc12c.zip


VR Venkateshwaran Ramdoss Syncfusion Team May 6, 2016 06:20 AM UTC

Hi Nick,

Thanks for your update.

A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Regards,
Venkateshwaran V.R. 


NT Nick Tang May 6, 2016 09:55 AM UTC

Hi Venkateshwaran,

Another two questions,
  1. How to store the QAT state (what ribbon buttons were listed in QAT) when closing main window? If the state of the QAT is saved last window closing, how to load it when startup main window? Is there any way to do it automatically by the ribbon?
  2. How to add the sub options of back stage into QAT?
    For example: there are three options under Info, how could I add these three options into QAT from customize ribbon window? The source code is attached.

Thanks.

Nick


Attachment: QATSample_20160506_85369121.zip


VR Venkateshwaran Ramdoss Syncfusion Team May 9, 2016 01:27 PM UTC

Hi Nick,

Query #1: How to store the QAT state when closing main window?

Our WPF Ribbon control have support for state persistance. We can persist Ribbon, QAT and RibbonWindow using State Persistance. You can refer the below documentation link for the same.

Link: http://help.syncfusion.com/wpf/ribbon/statepersistence

Query #2: How to add the sub options of back stage into QAT?

In our current implementation, we did have option to synchronize the second level items(items present inside BackStageTab) into QAT. You can register the items present in BackStageTabItem to "RibbonCommandManager" to add the required items into QAT.

Regards,
Venkateshwaran V.R.


NT Nick Tang May 11, 2016 06:39 AM UTC

Thank you. I have resolved my problem with the help of document online. But there is another issue, there was a function was called to clear QAT items and add some ribbons into QAT, after updated the QAT successfully, I closed the main window and restarted it. the QAT was empty, it didn't remeberer/loaded the QAT details.


Attachment: QATSample__persist_QAT_issue_65382160.zip


VR Venkateshwaran Ramdoss Syncfusion Team May 12, 2016 01:10 PM UTC

Hi Nick,

We have modified the sample based on your requirement. In this sample, we have added the item already in the Ribbon using "AddElementToQAT" property and "RibbonCommandManager.UniqueItemName". In your sample, you have tried to add the item which is created dynamically. We can not add the item dynamically into QuickAccessToolBar when the item did not placed in the Ribbon. Because we have serialized and de-serialized the item based on the position placed in Ribbon. Please download the sample from the below link.

Sample: QATSample 

Regards,
Venkateshwaran V.R.


NT Nick Tang May 16, 2016 09:00 AM UTC

Thanks a lot.


VR Venkateshwaran Ramdoss Syncfusion Team May 17, 2016 05:57 AM UTC

Hi Nick,

We are glad that your problem has been resolved. Please let us know if you need any other assistance.

Regards,
Venkateshwaran V.R. 


Loader.
Up arrow icon