I have written several articles about how to develop the ribbon toolbar in wpf4.ArticleThe WPF ribbon Control control library is used to develop a ribbon toolbar similar to the Office 2007 style. Of course, codeplex also provides the fluent ribbon Control Suite project to write the toolbar application of the office 2010 style.Program. In August 2, Microsoft officially released Microsoft ribbon for WPF. The ribbon control is a 100% all-in-one WPF tool and supports wpf3.5 SP1 and wpf4.
Download and install
First download the MSI installer.Microsoft ribbon for WPF source and samples. MSIThe program contains some source code and examples. After installation, the microsoftribbonforwpfsourceandsamples.zip project of vs2010 will be released in the C: \ Program Files \ microsoft ribbon for WPF \ v3.5.40729.1 directory.
Microsoft ribbon for WPF. MSIThe program is what we really need. After the program is installed, open vs2010 to create a project. In the Windows template, you can see the "WPF ribbon application" option.
Vs2010 demo
After the project is created, a default ribbon model has been compiled for us.
Look at the XAMLCode, Which is no different from the previous WPF ribbon control.
< Ribbon : Ribbonwindow X : Class = "Wpfribbonapplicationvs2010.mainwindow" Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation" Xmlns : X = "Http://schemas.microsoft.com/winfx/2006/xaml" Xmlns : Ribbon = "CLR-namespace: Microsoft. Windows. Controls. ribbon;
Assembly = ribboncontrolslibrary" Title = "Mainwindow" X : Name = "Ribbonwindow" Width = "640" Height = "480"> < Grid X : Name = "Layoutroot"> < Grid. rowdefinitions > < Rowdefinition Height = "Auto"/> < Rowdefinition Height = "*"/> </ Grid. rowdefinitions > < Ribbon : Ribbon X : Name = "Ribbon"> < Ribbon : Ribbon. applicationmenu > < Ribbon : Ribbonapplicationmenu Smallimagesource = "Images \ smallicon.png"> < Ribbon : Ribbonapplicationmenuitem Header = "Hello _ Ribbon" X : Name = "Menuitem1" Imagesource = "Images \ largeicon.png"/> </ Ribbon : Ribbonapplicationmenu > </ Ribbon : Ribbon. applicationmenu > < Ribbon : Ribbontab X : Name = "Hometab" Header = "Home"> < Ribbon : Ribbongroup X : Name = "Group1" Header = "Group1"> < Ribbon : Ribbonbutton X : Name = "Button1" Largeimagesource = "Images \ largeicon.png" Label = "Button1"/> < Ribbon : Ribbonbutton X : Name = "Button2" Smallimagesource = "Images \ smallicon.png" Label = "Button2"/> < Ribbon : Ribbonbutton X : Name = "Button3" Smallimagesource = "Images \ smallicon.png" Label = "Button3"/> < Ribbon : Ribbonbutton X : Name = "Button4" Smallimagesource = "Images \ smallicon.png" Label = "Button4"/> </ Ribbon : Ribbongroup > </ Ribbon : Ribbontab > </ Ribbon : Ribbon > </ Grid > </ Ribbon : Ribbonwindow >
Blend4 demo
What's even more exciting is that this ribbon Library also supports blend4, which makes it easier to design ribbon toolbar styles. You can also see the "WPF ribbon application" option when you open blend4 to create a project.
There are also many ribbon controls in the control library for your use.
On the basis of the current project, drag a ribbontab and name it "mytab ".
Adjust the scope of the mytab area in the design window.
After the tab label is designed, add the mygroup group to the mytab. For ease of design, hide the home label first.
Adjust the scope of the mygroup region.
Add the ribbonbutton and ribboncheckbox controls in mygroup, and set a small icon for ribbonbutton.
Next we will add some simple events for ribbonbutton and ribboncheckbox.
Private voidRibbonbutton_click (ObjectSender,RoutedeventargsE ){// Todo: Add event handler implementation here.MessageBox. Show ("Button clicked .");}
Private voidRibboncheckbox_checked (ObjectSender,RoutedeventargsE ){// Todo: Add event handler implementation here.MessageBox. Show ("Checked .");}
Private voidRibboncheckbox_unchecked (ObjectSender,RoutedeventargsE ){// Todo: Add event handler implementation here.MessageBox. Show ("Unchecked .");}
Through the simple demonstration above, ribbon for WPF released by Microsoft does save a lot of trouble for us to develop the ribbon toolbar, so we don't have to worry about complicated nested XAML code. For more information, see microsoftribbonforwpfsourceandsamples.zip.Source codeLearn more complex ribbon toolbar.
References
1. ribbon for WPF
2. WPF 4 ribbon development-quick access Toolbar)
3. WPF 4 ribbon development application menu)
4. WPF 4 ribbon development-label toolbar (Tab toolbar)
Tags: WPF