Visual Studio 2013 .NET WPF : Where do i get / can i find the WPF Ribbon Control?

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 VersionRelease (YYYY-MM).NET VersionVisual Studio VersionMajor Features
3.02006-113.0N/AInitial Release.
WPF development can be done with VS 2005 (released in Nov 2005) too with few additions as described here.
3.52007-113.5VS 2008Changes and improvements in:
Application model, data binding, controls, documents, annotations, and 3-D UI elements.
3.5 SP12008-083.5 SP1N/ANative splash screen support, New WebBrowser control, DirectX pixel shader support.
Faster startup time and improved performance for Bitmap effects.
4.02010-044.0VS 2010New controls: Calendar, DataGrid, and DatePicker.
Multi-Touch and Manipulation
4.52012-084.5VS 2012New Ribbon control
New INotifyDataErrorInfo interface
4.5.12013-104.5.1VS 2013No Major Change
4.5.22014-054.5.2N/ANo Major Change
4.62015-074.6VS 2015Transparent child window support
HDPI and Touch improvements
Which WPF Version is included in which version of the .NET Framework?

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“

In the Solution Explorer of your WPF Application right-click the References entry and choose „Add Reference“

3.) In the following dialog search for „Ribbon“ in the search field on the upper right

Search for Ribbon in the Dialog that appears by using the textbox on the upper right corner

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");
        }
    }
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.