Ribbon Example

Information for Developers

To add a ribbon tab for your plug-in, you need to use the INavContext interface. See INavContext Interface.

From it, you may call GetRibbon() to retrieve an IRibbon instance. With the IRibbon instance, you may add a new ribbon tab.

Here is an example using data binding to the IRibbonControlData/IRibbonMenuData interfaces. See IRibbonControlData Interface and IRibbonMenuData Interface.

Copy
private void CreatePluginRibbon()
{
    IRibbon ribbon = mNavigationContext.GetRibbon();
    IRibbonTab tab = ribbon.AddNewRibbonTab("PluginTab", "P");
    IRibbonGroup group = tab.AddNewRibbonGroup("PluginGroup");
    Button searchAndHighlightButton = group.AddRibbonButton(PluginViewModel.SearchHighlight);
    IRibbonComboBox comboMenu = group.AddRibbonCombobox(PluginViewModel.Fonts);
}

Here is sample code for the PluginViewModel.

Copy
public static classPluginViewModel
{
    private staticRibbonControlData _searchHighlight;
    private staticRibbonMenuData _fonts;
    public staticRibbonControlData SearchHighlight
    {
        get
        {
            if (_searchHighlight == null)
            {
                _searchHighlight = new RibbonControlData()
                {
                    Label = "Search and Highlight",
                    Command = new ButtonCommand(),
                    KeyTip = "S"
                };
            }
            return _searchHighlight;
        }
    }
    public staticRibbonMenuData Fonts
    {
        get
        {
            if (_fonts == null)
            {
                BitmapImage image = new BitmapImage(new Uri("C:/TFS/Trunk/ObjectApplications/Debug/Flare.app/Plugins/NavigationPlugin/Icons/EditDocument.png"));
                _fonts = new RibbonMenuData()
                {
                    Label = "My Fonts",
                    LargeImage = image
                };
                _fonts.ControlDataCollection.Add(new RibbonControlData()
                {
                    Label = "Arial"
                });
                _fonts.ControlDataCollection.Add(new RibbonControlData()
                {
                    Label = "Helvetica"
                });
                _fonts.ControlDataCollection.Add(new RibbonControlData()
                {
                    Label = "Times New Roman"
                });
            }
            return _fonts;
        }
    }
}

Note The ribbon tab is only visible when the Flare interface is in “Ribbon” mode.