I am trying to duplicate the Clipboard group within Word 2007's ribbon menu in my application. It will have a large paste ButtonTool and small ButtonTool for cut and copy. The entire ribbon (tabs, groups and tools) will be built programatically rather than with the designer. I am having trouble getting the paste button to show up larger. Listed below are the properties that I have set to try and accomplish this:
pasteButtonTool.InstanceProps.PreferredSizeOnRibbon = INFRATOOLBAR.RibbonToolSize.Large;pasteButtonTool.SharedProps.AppearancesLarge.Appearance.Image = Paste32x32;pasteButtonTool.SharedProps.Caption = "Paste";
I have examined the way it is accomplished when using the designer (in the code spit), and for some reason it creates 2 instances of a ButtonTool. Is that the only way to get that to work? There should be a way to make this happen without 2 ButtonTool objects.
thank-you
firstdata said: I am having trouble getting the paste button to show up larger. Listed below are the properties that I have set to try and accomplish this: pasteButtonTool.InstanceProps.PreferredSizeOnRibbon = INFRATOOLBAR.RibbonToolSize.Large;pasteButtonTool.SharedProps.AppearancesLarge.Appearance.Image = Paste32x32;pasteButtonTool.SharedProps.Caption = "Paste";
I am having trouble getting the paste button to show up larger. Listed below are the properties that I have set to try and accomplish this:
The ribbon is probably resizing the paste button tool to a smaller size due to a lack of space. You can prevent this by setting the MinimumSizeOnRibbon to Large as well.
firstdata said: I have examined the way it is accomplished when using the designer (in the code spit), and for some reason it creates 2 instances of a ButtonTool. Is that the only way to get that to work? There should be a way to make this happen without 2 ButtonTool objects.
Yes and no. Internally, each tool you create must have a 'root' tool that keeps all shared properties and shows up in the run-time customize dialog, even if the tool is not present on the ribbon or any toolbars. If that tool is also displayed on a ribbon group, toolbar, or menu, an additional 'instance' tool must be created to keep the instance properties of that specific instance of the tool being displayed. This is because the same tool can have a different caption, icon, preferred size on ribbon, ... in different places. So in your designer code, the 'root' tool is created and added to the toolbars manager's Tools collection. Then the 'instance' tool is created and added to the ribbon group's Tools collection. However, you don't need to create the instance tool. You can have the toolbars manager create it for you:
ButtonTool pasteButtonRootTool = new ButtonTool("Paste");
pasteButtonRootTool.SharedProps.AppearancesLarge.Appearance.Image = Paste32x32;
pasteButtonRootTool.SharedProps.Caption = "Paste";
this.ultraToolbarsManager.Tools.Add(pasteButtonRootTool);
ButtonTool pasteButtonInstanceTool = this.ultraToolbarsManager.Ribbon.Tabs[0].Groups[0].Tools.AddTool("Paste");
pasteButtonInstanceTool.InstanceProps.MinimumSizeOnRibbon = INFRATOOLBAR.RibbonToolSize.Large;
Thank you for your reply Mike. Is there a way to accomplish this without the use of a "Root" ButtonTool? I have acheived the desired look with the smaller ButtonTools (without the creation of a root ButtonTool) but not the large one. In my first post I failed to mention that not only is the button not showing up large, but the image is not showing either.
"The ribbon is probably resizing the paste button tool to a smaller size due to a lack of space. You can prevent this by setting the MinimumSizeOnRibbon to Large as well."
There where only a few tools on the tab to begin with... so I don't know if that would have been the case. Setting MinimumSizeOnRibbon to Large doesn't seem to work either.
"ButtonTool pasteButtonRootTool = new ButtonTool("Paste");pasteButtonRootTool.SharedProps.AppearancesLarge.Appearance.Image = Paste32x32;pasteButtonRootTool.SharedProps.Caption = "Paste";this.ultraToolbarsManager.Tools.Add(pasteButtonRootTool);ButtonTool pasteButtonInstanceTool = this.ultraToolbarsManager.Ribbon.Tabs[0].Groups[0].Tools.AddTool("Paste");pasteButtonInstanceTool.InstanceProps.MinimumSizeOnRibbon = INFRATOOLBAR.RibbonToolSize.Large;"
I tried to use your code also... I'm not sure if I have an older version or maybe missing a hot-fix because the compiler required me to cast the Group.AddTool method back to a ButtonTool... even though it is suppose to return a ToolBase.