Microsoft Ribbon for WPF 正式发布
2026/7/5 2:14:11 网站建设 项目流程

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: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 演示

更令人兴奋的是该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."); }

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询