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
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 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.
XML ribbon gives us more customization options than visual designer.