Overview

A short overview of available controls in Windows Ribbon Framework. This list will be updated from time to time until all controls are described. There are also some tips how to use the controls in Winforms projects. To test the described controls you will find a project which can be used to compile all snippets of Ribbon controls.

This blog contains a overview for most of Ribbon Controls available. You can generate a demo application with ProRibbon or by CommandLine. With ProRibbon Copy&Paste snippet, with CommandLine you can use this Blog to compile by command line.

Input files

Extract the demonstration project to "c:\temp\blogtemp\".

After extracting project open markup.xml (c:\temp\blogtemp\ProRibbonMarkup\markup.xml (Ribbon Markup Definition). Configuring the codeoutput is shown in video below.

PropertyValue
NamespaceProRibbonTest
Form Class NameFormTestProRibbon
Form Class Designer Ribbon Filec:\temp\blogtemp\ProRibbonTest\FormTestProRibbon.Designer.Ribbon.cs

The following files will be your point of interest:

  • c:\temp\blogtemp\ProRibbonMarkup\markup.xml (Ribbon Markup Definition)
  • c:\temp\blogtemp\ProRibbonMarkup\genmarkup.bat (Compile/Link/Copy Windows Ribbon Markup to C# Resource)
  • c:\temp\blogtemp\ProRibbonTest\FormTestProRibbon.ribbon (Compiled Ribbon Resource)
  • c:\temp\blogtemp\ProRibbonTest\FormTestProRibbon.Designer.Ribbon.cs (Modify only if you !DON'T! use ProRibbon. Initialization of Ribbon Infrastructure is done here.)
  • c:\temp\blogtemp\ProRibbonTest\FormTestProRibbon.cs (Copy C#-Snippets to method RunSnippet)

After download and extracting demonstration project to c:\temp, doesnt matter if you use commandline compile or ProRibbon-Mode you can test application bei opening c:\temp\blogtemp\ProRibbonTest\ProRibbonTest.sln and starting the application. Remember!!! Ribbon have only to be compiled after markup.xml is changed. The Sample project is delivered with a short markup, which will show you a button. The corresponding ribbon binaray (c:\temp\blogtemp\ProRibbonTest\FormTestProRibbon.ribbon) is already available. So you can start the application by pressing F5. In case you modify the the markup file. You have to update the binary. This can be done by ProRibbon or by commandline. In case of commandline you have to update c:\temp\blogtemp\ProRibbonMarkup\genmarkup.bat, execute the batch and change any access code for the changed markup c:\temp\blogtemp\ProRibbonTest\\FormTestProRibbon.Designer.Ribbon.cs. In case of ProRibbon you press Generate Ribbon default. To regenerate the .NET Source you go to the code editor and press save. All images used in example can be found here: Visual Studio Image Library

Windows Ribbon Framework Controls

Display in application

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://schemas.microsoft.com/windows/2009/Ribbon">
    <Application.Commands>
        <Command Name="TabDefault" LabelTitle="Default" Id="3" />
        <Command Name="TestButton" LabelTitle="My Button" Id="4">
            <Command.LargeImages>
                <Image Source=".\images\deficon.bmp" MinDPI="96" />
            </Command.LargeImages>
            <Command.SmallImages>
                <Image Source=".\images\deficon_small.bmp" MinDPI="96" />
            </Command.SmallImages>
        </Command>
    </Application.Commands>
    <Application.Views>
        <Ribbon GroupSpacing="Small">
            <Ribbon.Tabs>
                <Tab CommandName="TabDefault">
                    <Group>
                        <Button CommandName="TestButton" />
                    </Group>
                </Tab>
            </Ribbon.Tabs>
        </Ribbon>
    </Application.Views>
</Application>
// This file contains code to inject ribbon control to your form.
// Version 1.0
namespace ProRibbonTest
{
    using System;
    using System.ComponentModel;
    using System.Linq;    
    using System.Reflection;
    using System.Windows.Forms;
    using RibbonLib;
    using RibbonLib.Controls;
    public partial class FormTestProRibbon 
    {
        protected override void OnLoad(EventArgs e)
        {
            this.InitRibbonLib();
            base.OnLoad(e);
        }
        private RibbonLib.Ribbon InitRibbonLib(RibbonLib.Ribbon ribbon = null, string ribbonPath = @@"", string ribbonResource = @@"ProRibbonTest.FormTestProRibbon")
        {
            if (ribbon == null)
            {
                 ribbon = this.Controls.Cast<Control>().FirstOrDefault(a => a is Ribbon) as Ribbon;
                 if (ribbon == null)
                 {
                     ribbon = new Ribbon();
                     this.Controls.Add(ribbon);
                     this.Controls.SetChildIndex(ribbon, Math.Max(0, this.Controls.Count - 1));
                 }
            }
            
            // ribbonPath if you want to load from dll
            if (!string.IsNullOrEmpty(ribbonPath))
            {
                try
                {
                    var initFrameWork = ribbon.GetType()
                        .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
                        .First(method => method.Name == "InitFramework" && method.GetParameters().Count() == 2 && method.GetParameters()[1].ParameterType == typeof (string));
                    initFrameWork.Invoke(ribbon, new object[] {"APPLICATION_RIBBON", ribbonPath});
                }
                catch (Exception msg)
                {
                    MessageBox.Show(this, "Ribbon could not be loaded." + Environment.NewLine + msg.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            // ribbonResource if you want to load from resource
            if (!string.IsNullOrEmpty(ribbonResource))
            {
                ribbon.ResourceName = ribbonResource;
            }
            this.buttonTestButton = new RibbonButton(ribbon, 4);
            this.tabTabDefault = new RibbonTab(ribbon, 3);
            return ribbon;
        }
        public RibbonButton buttonTestButton;
        public RibbonTab tabTabDefault;
    
    
        public class RibbonContextMenuStrip : ContextMenuStrip
        {
            private uint contextPopupID;
            private Ribbon ribbon;
            public RibbonContextMenuStrip(Ribbon ribbon, uint contextPopupId)
                : base()
            {
                this.contextPopupID = contextPopupId;
                this.ribbon = ribbon;
            }
            protected override void OnOpening(CancelEventArgs e)
            {
                this.ribbon.ShowContextPopup(contextPopupID, Cursor.Position.X, Cursor.Position.Y);
                e.Cancel = true;
            }
        }
    }
}

Display in application

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://schemas.microsoft.com/windows/2009/Ribbon">
    <Application.Commands>
        <Command Name="TabDefault" LabelTitle="Default" Id="3" />
        <Command Name="TestButton" LabelTitle="My CheckBox" Id="4">
            <Command.LargeImages>
                <Image Source=".\images\deficon.bmp" MinDPI="96" />
            </Command.LargeImages>
            <Command.SmallImages>
                <Image Source=".\images\deficon_small.bmp" MinDPI="96" />
            </Command.SmallImages>
        </Command>
    </Application.Commands>
    <Application.Views>
        <Ribbon GroupSpacing="Small">
            <Ribbon.Tabs>
                <Tab CommandName="TabDefault">
                    <Group>
                        <CheckBox CommandName="TestButton" />
                    </Group>
                </Tab>
            </Ribbon.Tabs>
        </Ribbon>
    </Application.Views>
</Application>
// This file contains code to inject ribbon control to your form.
// Version 1.0
namespace ProRibbonTest
{
    using System;
    using System.ComponentModel;
    using System.Linq;    
    using System.Reflection;
    using System.Windows.Forms;
    using RibbonLib;
    using RibbonLib.Controls;
    public partial class FormTestProRibbon 
    {
        protected override void OnLoad(EventArgs e)
        {
            this.InitRibbonLib();
            base.OnLoad(e);
        }
        private RibbonLib.Ribbon InitRibbonLib(RibbonLib.Ribbon ribbon = null, string ribbonPath = "", string ribbonResource = "ProRibbonTest.FormTestProRibbon")
        {
            if (ribbon == null)
            {
                 ribbon = this.Controls.Cast<Control>().FirstOrDefault(a => a is Ribbon) as Ribbon;
                 if (ribbon == null)
                 {
                     ribbon = new Ribbon();
                     this.Controls.Add(ribbon);
                     this.Controls.SetChildIndex(ribbon, Math.Max(0, this.Controls.Count - 1));
                 }
            }
            
            // ribbonPath if you want to load from dll
            if (!string.IsNullOrEmpty(ribbonPath))
            {
                try
                {
                    var initFrameWork = ribbon.GetType()
                        .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
                        .First(method => method.Name == "InitFramework" && method.GetParameters().Count() == 2 && method.GetParameters()[1].ParameterType == typeof (string));
                    initFrameWork.Invoke(ribbon, new object[] {"APPLICATION_RIBBON", ribbonPath});
                }
                catch (Exception msg)
                {
                    MessageBox.Show(this, "Ribbon could not be loaded." + Environment.NewLine + msg.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            // ribbonResource if you want to load from resource
            if (!string.IsNullOrEmpty(ribbonResource))
            {
                ribbon.ResourceName = ribbonResource;
            }
            this.checkboxTestButton = new RibbonCheckBox(ribbon, 4);
            this.tabTabDefault = new RibbonTab(ribbon, 3);
            return ribbon;
        }
        public RibbonCheckBox checkboxTestButton;
        public RibbonTab tabTabDefault;
    
    
        public class RibbonContextMenuStrip : ContextMenuStrip
        {
            private uint contextPopupID;
            private Ribbon ribbon;
            public RibbonContextMenuStrip(Ribbon ribbon, uint contextPopupId)
                : base()
            {
                this.contextPopupID = contextPopupId;
                this.ribbon = ribbon;
            }
            protected override void OnOpening(CancelEventArgs e)
            {
                this.ribbon.ShowContextPopup(contextPopupID, Cursor.Position.X, Cursor.Position.Y);
                e.Cancel = true;
            }
        }
    }
}

Display in application

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://schemas.microsoft.com/windows/2009/Ribbon">
    <Application.Commands>
        <Command Name="TabDefault" LabelTitle="Default" Id="3" />
        <Command Name="ComboBoxCmd" Id="4"></Command>
        <Command Name="Btn1" LabelTitle="Btn1" Id="5" />
        <Command Name="Btn2" LabelTitle="Btn2" Id="6" />
        <Command Name="ComboBoxCm2" Id="7"/>
    </Application.Commands>
    <Application.Views>
        <Ribbon GroupSpacing="Small">
            <Ribbon.Tabs>
                <Tab CommandName="TabDefault">
                    <Group>
                        <ComboBox ResizeType="NoResize" IsEditable="false" IsAutoCompleteEnabled="true" CommandName="ComboBoxCmd"/>
                        <ComboBox ResizeType="VerticalResize" IsEditable="true" IsAutoCompleteEnabled="true" CommandName="ComboBoxCm2"/>
                        <Button CommandName="Btn1" />
                        <Button CommandName="Btn2" />
                    </Group>
                </Tab>
            </Ribbon.Tabs>
        </Ribbon>
    </Application.Views>
</Application>
// This file contains code to inject ribbon control to your form.
// Version 1.0
namespace ProRibbonTest
{
    using System;
    using System.ComponentModel;
    using System.Linq;    
    using System.Reflection;
    using System.Windows.Forms;
    using RibbonLib;
    using RibbonLib.Controls;
    public partial class FormTestProRibbon 
    {
        protected override void OnLoad(EventArgs e)
        {
            this.InitRibbonLib();
            base.OnLoad(e);
        }
        private RibbonLib.Ribbon InitRibbonLib(RibbonLib.Ribbon ribbon = null, string ribbonPath = "", string ribbonResource = "ProRibbonTest.FormTestProRibbon")
        {
            if (ribbon == null)
            {
                 ribbon = this.Controls.Cast<Control>().FirstOrDefault(a => a is Ribbon) as Ribbon;
                 if (ribbon == null)
                 {
                     ribbon = new Ribbon();
                     this.Controls.Add(ribbon);
                     this.Controls.SetChildIndex(ribbon, Math.Max(0, this.Controls.Count - 1));
                 }
            }
            
            // ribbonPath if you want to load from dll
            if (!string.IsNullOrEmpty(ribbonPath))
            {
                try
                {
                    var initFrameWork = ribbon.GetType()
                        .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
                        .First(method => method.Name == "InitFramework" && method.GetParameters().Count() == 2 && method.GetParameters()[1].ParameterType == typeof (string));
                    initFrameWork.Invoke(ribbon, new object[] {"APPLICATION_RIBBON", ribbonPath});
                }
                catch (Exception msg)
                {
                    MessageBox.Show(this, "Ribbon could not be loaded." + Environment.NewLine + msg.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            // ribbonResource if you want to load from resource
            if (!string.IsNullOrEmpty(ribbonResource))
            {
                ribbon.ResourceName = ribbonResource;
            }
            this.buttonBtn1 = new RibbonButton(ribbon, 5);
            this.buttonBtn2 = new RibbonButton(ribbon, 6);
            this.comboboxComboBoxCmd = new RibbonComboBox(ribbon, 4);
            this.comboboxComboBoxCm2 = new RibbonComboBox(ribbon, 7);
            this.tabTabDefault = new RibbonTab(ribbon, 3);
            return ribbon;
        }
        public RibbonButton buttonBtn1;
        public RibbonButton buttonBtn2;
        public RibbonComboBox comboboxComboBoxCmd;
        public RibbonComboBox comboboxComboBoxCm2;
        public RibbonTab tabTabDefault;
    
    
        public class RibbonContextMenuStrip : ContextMenuStrip
        {
            private uint contextPopupID;
            private Ribbon ribbon;
            public RibbonContextMenuStrip(Ribbon ribbon, uint contextPopupId)
                : base()
            {
                this.contextPopupID = contextPopupId;
                this.ribbon = ribbon;
            }
            protected override void OnOpening(CancelEventArgs e)
            {
                this.ribbon.ShowContextPopup(contextPopupID, Cursor.Position.X, Cursor.Position.Y);
                e.Cancel = true;
            }
        }
    }
}
        private void RunSnippet(object sender, EventArgs e)
        {
            var categories2 = comboboxComboBoxCm2.Categories;
            categories2.Clear();
            categories2.Add(new GalleryItemPropertySet { Label = "Cat1", CategoryID = 1 });
            categories2.Add(new GalleryItemPropertySet { Label = "Cat2", CategoryID = 2 });
            var itemsSource2 = comboboxComboBoxCm2.ItemsSource;
            itemsSource2.Clear();
            itemsSource2.Add(new GalleryItemPropertySet { Label = "1.0", CategoryID = 1 });
            itemsSource2.Add(new GalleryItemPropertySet { Label = "2.0", CategoryID = 1 });
            itemsSource2.Add(new GalleryItemPropertySet { Label = "5.3", CategoryID = 2 });
        }

Display in application (here you see a screenshot made in ProRibbon)

                         <?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://schemas.microsoft.com/windows/2009/Ribbon">
    <Application.Commands>
        <Command Name="TabDefault" LabelTitle="Default" Id="3" />
        <Command Name="ComboBoxCmd" Id="4"></Command>
        <Command Name="Btn1" LabelTitle="Btn1" Id="5">
            <Command.LargeImages>
                <Image Source=".\images\deficon.bmp" MinDPI="96" />
            </Command.LargeImages>
            <Command.SmallImages>
                <Image Source=".\images\deficon_small.bmp" MinDPI="96" />
            </Command.SmallImages>
        </Command>
        <Command Name="Btn2" LabelTitle="Btn2" Id="6">
            <Command.LargeImages>
                <Image Source=".\images\deficon.bmp" MinDPI="96" />
            </Command.LargeImages>
            <Command.SmallImages>
                <Image Source=".\images\deficon_small.bmp" MinDPI="96" />
            </Command.SmallImages>
        </Command>
        <Command Name="ComboBoxCm2" Id="7" />
        <Command Name="MenuCmd" LabelTitle="My Menu" Id="8" />
    </Application.Commands>
    <Application.Views>
        <Ribbon GroupSpacing="Small">
            <Ribbon.Tabs>
                <Tab CommandName="TabDefault">
                    <Group>
                        <ComboBox ResizeType="NoResize" IsEditable="false" IsAutoCompleteEnabled="true" CommandName="ComboBoxCmd" />
                        <ComboBox ResizeType="VerticalResize" IsEditable="true" IsAutoCompleteEnabled="true" CommandName="ComboBoxCm2" />
                        <Button CommandName="Btn1" />
                        <Button CommandName="Btn2" />
                    </Group>
                </Tab>
            </Ribbon.Tabs>
        </Ribbon>
        <ContextPopup>
            <ContextPopup.ContextMenus>
                <ContextMenu Name="MyMenu">
                    <MenuGroup Class="StandardItems">
                        <Button CommandName="Btn1" />
                        <Button CommandName="Btn2" />
                    </MenuGroup>
                </ContextMenu>
            </ContextPopup.ContextMenus>
            <ContextPopup.ContextMaps>
                <ContextMap CommandName="MenuCmd" ContextMenu="MyMenu" />
            </ContextPopup.ContextMaps>
        </ContextPopup>
    </Application.Views>
</Application>
                
// This file contains code to inject ribbon control to your form.
// Version 1.0
namespace ProRibbonTest
{
    using System;
    using System.ComponentModel;
    using System.Linq;    
    using System.Reflection;
    using System.Windows.Forms;
    using RibbonLib;
    using RibbonLib.Controls;
    public partial class FormTestProRibbon 
    {
        protected override void OnLoad(EventArgs e)
        {
            this.InitRibbonLib();
            base.OnLoad(e);
        }
        private RibbonLib.Ribbon InitRibbonLib(RibbonLib.Ribbon ribbon = null, string ribbonPath = "", string ribbonResource = "ProRibbonTest.FormTestProRibbon")
        {
            if (ribbon == null)
            {
                 ribbon = this.Controls.Cast<Control>().FirstOrDefault(a => a is Ribbon) as Ribbon;
                 if (ribbon == null)
                 {
                     ribbon = new Ribbon();
                     this.Controls.Add(ribbon);
                     this.Controls.SetChildIndex(ribbon, Math.Max(0, this.Controls.Count - 1));
                 }
            }
            
            // ribbonPath if you want to load from dll
            if (!string.IsNullOrEmpty(ribbonPath))
            {
                try
                {
                    var initFrameWork = ribbon.GetType()
                        .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
                        .First(method => method.Name == "InitFramework" && method.GetParameters().Count() == 2 && method.GetParameters()[1].ParameterType == typeof (string));
                    initFrameWork.Invoke(ribbon, new object[] {"APPLICATION_RIBBON", ribbonPath});
                }
                catch (Exception msg)
                {
                    MessageBox.Show(this, "Ribbon could not be loaded." + Environment.NewLine + msg.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            // ribbonResource if you want to load from resource
            if (!string.IsNullOrEmpty(ribbonResource))
            {
                ribbon.ResourceName = ribbonResource;
            }
            this.buttonBtn1 = new RibbonButton(ribbon, 5);
            this.buttonBtn2 = new RibbonButton(ribbon, 6);
            this.comboboxComboBoxCmd = new RibbonComboBox(ribbon, 4);
            this.comboboxComboBoxCm2 = new RibbonComboBox(ribbon, 7);
            this.tabTabDefault = new RibbonTab(ribbon, 3);
            this.contextmapMenuCmd = new RibbonContextMenuStrip(ribbon, 8);
            return ribbon;
        }
        public RibbonButton buttonBtn1;
        public RibbonButton buttonBtn2;
        public RibbonComboBox comboboxComboBoxCmd;
        public RibbonComboBox comboboxComboBoxCm2;
        public RibbonTab tabTabDefault;
        public RibbonContextMenuStrip contextmapMenuCmd;
    
    
        public class RibbonContextMenuStrip : ContextMenuStrip
        {
            private uint contextPopupID;
            private Ribbon ribbon;
            public RibbonContextMenuStrip(Ribbon ribbon, uint contextPopupId)
                : base()
            {
                this.contextPopupID = contextPopupId;
                this.ribbon = ribbon;
            }
            protected override void OnOpening(CancelEventArgs e)
            {
                this.ribbon.ShowContextPopup(contextPopupID, Cursor.Position.X, Cursor.Position.Y);
                e.Cancel = true;
            }
        }
    }
}