Search code examples
c#wpfribbon

The tag 'Ribbon' does not exist in XML namespace


I am trying to develop a WPF Application with Ribbon Control on .Net 4.5 Framework. As far as I know, MSDN Ribbon Class is now included in the Net 4.5 framework, therefore, I don't need to add this anymore.

But when I try to add this code :

<Window x:Class="WpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <StackPanel>
        <Ribbon>
        </Ribbon>
    </StackPanel>
</Window>

I got the following error. Am I missing something?

The tag 'Ribbon' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

EDIT :

using System.Windows.Controls.Ribbon;

also does not work.

The type or namespace name 'Ribbon' does not exist in the namespace 'System.Windows.Controls' (are you missing an assembly reference?)  c:\tmp\tst2\tst2\MainWindow.xaml.cs

Solution

  • You need to add a reference to System.Windows.Controls.Ribbon.dll (which is part of the .NET 4.5 framework. Then you need to add the namespace to your XAML, something like:

    xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
    

    to your window to get the namespace, then you can use it like

    <ribbon:Ribbon ... />
    

    like Cole Johnson said.

    Here's the MSDN reference on the Ribbon class, which shows all this information.