A serious project on an Office-like Ribbon control
(源程序及演示下载)
Introduction
Because of the lack of good free Ribbon controls on the web, I decided to write on
Why not WPF? Well mainly, because I needed the Ribbon to add it to my existing WinForms applications. In my opinion (the short version) this is not a “no” to WPF, is just a “not yet”. Anyway, you can host a WinForms control in WPF (See http://msdn.microsoft.com/en-us/library/ms750944.aspx).
Some of the design goals
Performance – This ribbon is contained on a Control window, and every element inside of it is managed as a bunch of bounds inside the control, just as the ToolStrip control does. Altough this is difficult to manage from the ribboon’s inside co
Consistency with Office’s ribbon – I read on
Ease of use for programmers – The naming of components is consistent with most WinForms naming system, even more with the ToolStrip elements. Property, event and method names for similar elements are named just like in the ToolStrip technology items.
Designer support – I will be adding more and more designer support so you can manage the ribbon 100% from the designer. Give it a try.
I will be providing updates and fixes for bugs, as I discover them or you kindly let me know about them.
Using the Ribbon
The ribbon is located in the
You can add a reference to the compiled dll: System.Windows.Forms.Ribbon.dll or you can directly copy the source files to a folder on your project. The co
Hands on: Quick Guide
The ribbon is composed mainly by three kind of elements, the tabs, the panels on the tabs (other developers call them groups) and the items inside the panels.
These elements are represented by
You can add tabs from the smart tag of the Ribbon, you can add panels to the tab by selecting the tab and calling the “AddPanel” verb on the bottom part of the property grid.
The elements on the ribbon are resized according to the available space for the ribbon. This is a key feature of the ribbon. It tries to bring all possible commands to the screen by resizing them, instead of hidding them on an overflow button like the old ToolStrip.
I treat this as three kinds of sizes: Large, Medium and Compact. An additional size is used for panels, because panels can be collapsed, and then they will adopth the Overflow size.
Note: There’s no way to directly affect the bounds of the elements on the ribbon, the size will always be determined the layout engine inside the ribbon. In fact, the layout depends on two factors: the available horizontal space on the ribbon and the size modes on the items.
If there’s no available space on the ribbon for a panel, panel will be collapsed. If all panels are collapsed and space is not available yet, a scroll button will appear so user can scroll the panels horizontally.
Buttons
There’s on
Note: Use the
The appearance of the buttons vary thru size modes.
ItemGroups
The buttons like those on the Font and Paragraph panels are
Items added to
Imp
Lists
Lists are represented by
If you want the buttons on the list to be shown on the dropdown, you will have to explicitly add another list with those buttons to the
Separators
Separators are represented by
Known Bugs
– Multiple dropdowns not managed accurately
– Drawing of collapsed panels when mouse down
Things to do
– Contextual tabs
– ToolTips
– (OK) TextBox, ComboBox
– Checkbox and NumericUpDown RibbonItems
– Orb and Quickaccess tools
– Vista clientarea docking
– Keyboard quick access thru Alt key
– Font and Color selectors
– Right to left orientation
– Ribbon minimization
History
- 8 May 2008 – Original Post
- 29 May 2008 – Update
DE<Enabled DE<property now working - Added
DE<RibbonTextBox DE<- A regular textbox with label and image - Added
DE<RibbonComboBox DE<- (Interited from DE<RibbonTextBox DE<) Offers a dropdown - Added
DE<RibbonColorChooser DE<- A button that shows a color bar. See property DE<Color DE<
License
This article, along with any associated source co
About the Author
Jose M. Menendez Poó
![]() |
Jose Manuel Menéndez Poó Mexico I’ve been programming Windows and Web apps since 1997. My greatest concern nowadays is user interface usability. My blog: www.menendezpoo.com
|