Customization of MS Project Add-in Ribbon using XML

Ram.kanumuri
Posted by in Others category on for Intermediate level | Points: 250 | Views : 7056 red flag

MS project Add-in allows us to create ribbon through XML. XML provides many options to customize ribbon controls like place our custom images to controls, screen tip, super tip, enable/disable etc.

The following covers the customization ways of MS project Ribbon using XML. 


1.       Adding xml ribbon to project:  Add New Item à Select Ribbon (XML). (name it as “CustomRibbon.cs”) 



 
2.       The above action crates the two files one is “xml” and another one is “cs” file CustomRibbon.xml and CustomRibbon.cs). XML is for designing ribbon controls  and CS file for ribbon controls call back events. By default CS file has Ribbon_Load which initializes our custom ribbon (IRibbonUI). 



a.       To enable this ribbon in add-in mpp client, we need to extend the override method “ CreateRibbonExtensibilityObject” in ThisAddIn.cs (Add-in created this file by default) file.  


   
b.      Add controls: Default xml for ribbon as follows, 



Xml element explanation:

<ribbon> tag is root element and under that <tabs> element which is for collection of individual tabs. <tab>, this for tab control and we can this tabs on ribbon. Our business of customization starts from here. <group>, is for maintaining collection of controls like GroupBox control in win forms. We have to add our controls under this <group> element.
 
We can modify this xml as per our need. Example, we want to have one button with an image, super tip screen tip and event on click. XML for this would look like this.



This xml gives us the ribbon as,


Interesting and important attributes for this button control are “getImage” and “onAction” , rest all are straight forward. The attribute getImage=”GetImage”, GetImage is a call back method in CustomRibbon.cs file and this method returns the image

This method takes the image and converts the image from bitmap. Here we need to do two things to work above method. 


o   Add “SubmitImg.bmp” image file to Resources of the project.
o   Write image converter from Bitmap as below,
                
 And another attribute is “onAction = OnbtnSubmitClick”, which is also a ribbon callback in CustomRibbon.cs.                            

Conclusion:

 XML ribbon gives us more customization options than visual designer.

Page copy protected against web site content infringement by Copyscape

About the Author

Ram.kanumuri
Full Name: Kodanda Ramaiah Kanumuri
Member Level: Starter
Member Status: Member
Member Since: 4/6/2011 2:19:52 AM
Country: India

http://www.dotnetfunda.com
I have good experience on EPM 2010

Login to vote for this post.

Comments or Responses

Posted by: Karthikanbarasan on: 4/7/2011 | Points: 25
Good one... images are not that much clear!!!

Login to post response

Comment using Facebook(Author doesn't get notification)