I Try to make a Quickaccestoolbar. I ahve the following code :
ButtonTool
btnToolCopy = new ButtonTool();
btnToolCopy.Id =
"copyTool";
// Adding ButtonTool to the QAT
qatToolCopy.TargetId =
// btnToolCopy.Id
qatToolCopy.TargetType =
QatPlaceholderToolType.Tool;
this.xamRibbon1.QuickAccessToolbar.Items.Add(qatToolCopy);
But i get a exception error :
An item with the specified TargetId 'copyTool' being added to the QuickAccessToolbar is not registered with the associated XamRibbon.
Thank you for help CaisseOdev
Hi Caisse,
The reason for the error is the ButtonTool must be added to the XamRibbon before it can be added to the QAT. To add the ButtonTool to the XamRibbon you'll need to add it to a XamRibbon group. This link demonstrates how you can do this: http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=xamRibbon_Add_Tools_to_a_Ribbon_Group.html
After the ButtonTool has been added to the group, you can add it to the QAT.http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=xamRibbon_Add_a_Tool_or_RibbonGroup_to_the_Quick_Access_Toolbar.html
Let me know if you have any questions on this.
Thank you for the answer , but I Have always the following error :
An item with the specified TargetId 'btnBold' being added to the QuickAccessToolbar is not registered with the associated XamRibbon.
Here is my code :
RibbonGroup
RibbonGroup group = new RibbonGroup();
group.caption = "Font";
group.id = "grpfont";
buttonTool btnTool = new ButtonTool();
btnTool.Caption = "Bold";
btnTool.Id = "btnBold";
group.Items.Add(btnTool);
QatPlaceholderTool btnBoldPH = new QatPlaceholderTool("btnBold"
);
//If you need to add a RibbonGroup to the QAT, you have to set the TargetType to RibbonGroup
QatPlaceholderTool tab1_group1PH = new QatPlaceholderTool("grpFont", QatPlaceholderToolType
.RibbonGroup);
//Replace xamRibbon1 with the instance variable of your xamRibbon
this.xamRibbon1.QuickAccessToolBar.Items.Add(btnBoldPH);
this.xamRibbon1.QuickAccessToolbar.Items.Add(tab1_group1PH);
WHERE IS ERROR ?
thank you CaisseOdev
Your almost there. I should have explained how to add the RibbonGroup to the Ribbon itself.
So now that you have your ribbon group you need to add it to a ribbon tab and then you need to add the tab to the ribbon's Tabs collection. The following bit of code will show you how to do this.
Thank you very much . I Have Understanded , I Forgot add a new tab.
Other Question : how you do to insert Code in the post for this forum ?
Thank you CaiseOdeV
No problem. Glad I could help.
For pasting code into a forum post I use the Visual Studio Add-In called Copy As HTML to convert the code into html.
http://visualstudiogallery.msdn.microsoft.com/98fef791-eb65-4cdf-bf84-077b98c234cf/
thank you