Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Ribbon in WPF App with with Visual Studio 2017

I've created a new WPF App in Visual Studio 2017 for Windows Classic Desktop.

I've tried to find how to add a Ribbon, but what I've found is related to old versions of Visual Studio and don't seem to work here, or I've didn't understood how to do it.

How can I add a Ribbon control in XAML/WPF using Visual Studio 2017?

EDIT:

I've obtained something with this XAML code:

<Window x:Class="WMathTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon.Primitives;assembly=System.Windows.Controls.Ribbon"
        xmlns:local="clr-namespace:WMathTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <DockPanel>
        <Ribbon>
            <ribbon:RibbonTabsPanel></ribbon:RibbonTabsPanel>

        </Ribbon>

    </DockPanel>
</Window>

enter image description here

It's something but it's a Ribbon window inside another window; the ribbon bar does not contain window name and buttons as in normal applications with ribbons.

like image 722
Jepessen Avatar asked Mar 10 '17 18:03

Jepessen


1 Answers

You need to add the following Reference: System.Windows.Controls.Ribbon

Then use a RibbonWindow instead of a Window:

<RibbonWindow ...

Also remember to change the base class of the partial:

using System.Windows.Controls.Ribbon;

public partial class MainWindow : RibbonWindow
{
    public MainWindow()
    {
        InitializeComponent();
    }
}
like image 114
Rauland Avatar answered Sep 29 '22 11:09

Rauland