Problem
According to the .NET documentation the Ribbon Control should be available since WPF 4.5, what means is available since .NET Framework 4.5 . But you can not find it? Are you even thinking about the download of the Ribbon control for older versions? Not necessary, please see the following points…
Approach
We have to find out the right moment when it is generally possible to use the Ribbon control.
The following table shows, that the first version of WPF (3.0) was released with the .NET Framework 3.0. As you can see the version number of WPF is maintained synchron with the version number of the .NET framework.
WPF Version | Release (YYYY-MM) | .NET Version | Visual Studio Version | Major Features |
---|---|---|---|---|
3.0 | 2006-11 | 3.0 | N/A | Initial Release. WPF development can be done with VS 2005 (released in Nov 2005) too with few additions as described here. |
3.5 | 2007-11 | 3.5 | VS 2008 | Changes and improvements in: Application model, data binding, controls, documents, annotations, and 3-D UI elements. |
3.5 SP1 | 2008-08 | 3.5 SP1 | N/A | Native splash screen support, New WebBrowser control, DirectX pixel shader support. Faster startup time and improved performance for Bitmap effects. |
4.0 | 2010-04 | 4.0 | VS 2010 | New controls: Calendar, DataGrid, and DatePicker. Multi-Touch and Manipulation |
4.5 | 2012-08 | 4.5 | VS 2012 | New Ribbon control New INotifyDataErrorInfo interface |
4.5.1 | 2013-10 | 4.5.1 | VS 2013 | No Major Change |
4.5.2 | 2014-05 | 4.5.2 | N/A | No Major Change |
4.6 | 2015-07 | 4.6 | VS 2015 | Transparent child window support HDPI and Touch improvements |
Solution
When you have installed at least .NET Framework 4.5 you can Add the Reference „System.Windows.Control.Ribbon“ as follows:
1.) Expand the tree in in your Solution Explorer of you WPF application
2.) Right-click the „Add References“ entry and choose „Add Reference“
3.) In the following dialog search for „Ribbon“ in the search field on the upper right
4.) After that you should be able to add the reference by using the checkbox
5.) In your XAML Code you are now able to use the <Ribbon/> Tag
Optional: 6.) If you want to use a RibbonWindow instead of a WPF Window which allows you to have the Quick Access Controls at the top of the window, you have to do the declaration in the head of MainWindow.xaml as follows:
<ribbon:RibbonWindow x:Class="WPFTutorial.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
Title="WPF Layoutmanager" Height="399" Width="763">
<DockPanel LastChildFill="True">
<Ribbon DockPanel.Dock="Top" >
</Ribbon>
<!-- Put the last Child here -->
</DockPanel>
</ribbon:RibbonWindow>
Additionally you have to change the base class name in the code behind window and add the using System.Windows.Controls.Ribbon :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFTutorial
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : RibbonWindow
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Test");
}
}
}