Ribbons in Outlook

The Outlook application supports the Ribbon in individual Inspectors, but not on the main Outlook window (the Explorer). The Explorer has the traditional menu and toolbars that you are familiar with; however, if you open an individual e-mail item, task, meeting request, or other Outlook item (Inspector), the UI displays the Ribbon.

In this section you'll create an Outlook add-in project that has two Ribbons. The first one will be used for the read mail Inspector, and the second one will be used for the contact Inspector.

1. Create an Outlook project using VSTO 2005 SE, and name it SimpleOutlookRibbon. Note that the name is important for the application to read the resources correctly.

2. Press CTRL+SHIFT+A to open the Add New Item dialog, and add a new Ribbon Support item. Name it RibbonHandler.vb.

3. Rename the RibbonHandler.xml file to ReadMailRibbon.xml.

4. Copy the ReadMailRibbon.xml file, and name the copy ContactRibbon.xml.

5. Right-click the ReadMailRibbon.xml file, and select Open, as shown in Figure 14.31.

Properties

Figure 14.31. Opening the ReadMailRibbon.xml file

Properties

Figure 14.31. Opening the ReadMailRibbon.xml file

6. Add the code in Listing 14.16 to the ReadMailRibbon.xml file.

There are two ways you can handle the event of pressing the toggle button. The first is to create two separate methods and then assign the appropriate method name to the onAction attribute of the toggle button. The second way is to have a generic method that checks the ID of the control to determine which button was pressed. You can append the name of the XML file to make it easy to identify which button is clicked. In the ReadMailRibbon.xml file, each ToggleButton control defines a separate onAction value.

Listing 14.16. Changing the ReadMailRibbon XML file

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/ customui"

onLoad="ReadMailRibbonOnLoad"> <ribbon> <tabs>

<tab id="ReadMailRibbon.Tab" label="ReadMailRibbon Tab"> <group id="ReadMailRibbon.Group" label="ReadMailRibbon Group">

<toggleButton id="ReadMailRibbon.toggleButton1" label="ReadMailRibbon Toggle Button 1" screentip="ToggleButton1 Screentip" onAction="ReadMailRibbonOnToggleButton1" />

<toggleButton id="ReadMailRibbon.toggleButton2" label="ReadMailRibbon Toggle Button 2" screentip="ToggleButton2 Screentip" onAction="OnToggleButton" />

</group> </tab> </tabs> </ribbon> </customUI>

0 0

Post a comment