7

I am unable to get a WPF Ribbon project to show in Visual Studio. Here is a link to a thread for someone that had an issue in Visual Studio 2010.

I have tried everything suggested there but to no avail.

I have Visual Studio 2012 Express for Desktop installed but nothing is showing up. I have tried uninstalling and re-installing but no luck.

Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
James Satori-Brunet
  • 901
  • 2
  • 13
  • 28

1 Answers1

15

A simple work around would be to simply replace <Window> with <RibbonWindow> and <Ribbon> as the first child. Keep in mind that the Ribbon control is already integrated into .NET 4.5.

First edit your MainWindow.xaml by replacing Window with RibbonWindow and add <Ribbon x:Name="Ribbon" Title="Ribbon Title">.

Example:

<RibbonWindow x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow"
        x:Name="RibbonWindow"
        Width="640" Height="480">

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Ribbon x:Name="Ribbon" Title="Ribbon Title">
            ...........
        </Ribbon>
    </Grid>
</RibbonWindow>

You will also need to edit the MainWindow.xaml.cs to inherit the RibbonWindow class instead of Window.

public partial class MainWindow : RibbonWindow

Last remember to import the reference from the .NET Framework.

System.Windows.Controls.Ribbon

Edit: Update with solution for VB.Net.

1) Add reference

  • Right click on your project and choose Add Reference.
  • Find System.Windows.Controls.Ribbon under Assemblies and Framework.
  • Click OK to save.

2) Edit your MainWindow.xaml

  • Back up any existing code.
  • Replace the default template with the code in my Example.
  • Add your new content within the <Ribbon></Ribbon> tag.

3) Edit your Mainwindow.xaml.vb

  • Right click on MainWindow.xaml and click View Code.
  • Change Class Window to Class RibbonWindow.

4) Run the program!

eandersson
  • 25,781
  • 8
  • 89
  • 110