Microsoft Ribbon for WPF 正式发布 Microsoft Ribbon for WPF Source and Samples.msi程序包括一些源码及实例安装后VS2010 版的项目开发包MicrosoftRibbonForWPFSourceAndSamples.zip 会释放在C:\Program Files\Microsoft Ribbon for WPF\v3.5.40729.1 目录中。Microsoft Ribbon for WPF.msi程序就是我们真正需要的东西程序安装后打开VS2010 新建项目在Windows 模板中可以看到WPF Ribbon Application 的选项。VS2010 演示新建项目后一个默认Ribbon 模型已经为我们编写好了。看看XAML 代码与原来用过的WPF Ribbon Control 也无太多差异。ribbon:RibbonWindow x:ClassWpfRibbonApplicationVS2010.MainWindow xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml xmlns:ribbonclr-namespace:Microsoft.Windows.Controls.Ribbon; assemblyRibbonControlsLibrary TitleMainWindow x:NameRibbonWindow Width640 Height480 Grid x:NameLayoutRoot Grid.RowDefinitions RowDefinition HeightAuto/ RowDefinition Height*/ /Grid.RowDefinitions ribbon:Ribbon x:NameRibbon ribbon:Ribbon.ApplicationMenu ribbon:RibbonApplicationMenu SmallImageSourceImages\SmallIcon.png ribbon:RibbonApplicationMenuItem HeaderHello _Ribbon x:NameMenuItem1 ImageSourceImages\LargeIcon.png/ /ribbon:RibbonApplicationMenu /ribbon:Ribbon.ApplicationMenu ribbon:RibbonTab x:NameHomeTab HeaderHome ribbon:RibbonGroup x:NameGroup1 HeaderGroup1 ribbon:RibbonButton x:NameButton1 LargeImageSourceImages\LargeIcon.png LabelButton1 / ribbon:RibbonButton x:NameButton2 SmallImageSourceImages\SmallIcon.png LabelButton2 / ribbon:RibbonButton x:NameButton3 SmallImageSourceImages\SmallIcon.png LabelButton3 / ribbon:RibbonButton x:NameButton4 SmallImageSourceImages\SmallIcon.png LabelButton4 / /ribbon:RibbonGroup /ribbon:RibbonTab /ribbon:Ribbon /Grid /ribbon:RibbonWindowBlend4 演示更令人兴奋的是该Ribbon 库同样支持Blend4这样可以更方便的设计Ribbon 工具栏样式。打开Blend4 新建项目也能看到WPF Ribbon Application的选项。在控件库里也有不少的Ribbon 控件供大家使用。在当前项目基础上拖拽一个RibbonTab 进来并将Tab 命名为MyTab。在设计窗口调整MyTab 区域范围。Tab 标签设计完成后继续在MyTab 中添加MyGroup 组为了设计方便先将Home 标签隐藏。调整MyGroup 区域范围。在MyGroup 中添加RibbonButton 和RibbonCheckBox 控件并为RibbonButton 设置一个Small 图标。接下来为添加RibbonButton 和RibbonCheckBox 一些简单的事件。private void ribbonButton_Click(object sender, RoutedEventArgs e) { // TODO: Add event handler implementation here. MessageBox.Show(Button Clicked.); }private void RibbonCheckBox_Checked(object sender, RoutedEventArgs e) { // TODO: Add event handler implementation here. MessageBox.Show(Checked.); }private void RibbonCheckBox_Unchecked(object sender, RoutedEventArgs e) { // TODO: Add event handler implementation here. MessageBox.Show(UnChecked.); }