Ribbon sample

tom7 picture tom7 · Jul 8, 2009 · Viewed 24.9k times · Source

I am using the WPF ribbon CTP from Microsoft. However, there is no sample. I am not sure where to start. The RibbonWindow does not have a property for the Ribbon. Does anyone have a sample that works?

Answer

Nattrass picture Nattrass · Oct 19, 2014

If you're using the WPF Ribbon http://msdn.microsoft.com/en-us/library/ff799534(v=vs.100).aspx

The MSDN documentation has good examples on how to use each component.

http://msdn.microsoft.com/en-us/library/microsoft.windows.controls.ribbon(v=vs.100).aspx

<r:RibbonWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        x:Class="MainWindowView"
        Title="MainWindowView" Height="300" Width="515">
    <DockPanel>
        <r:Ribbon DockPanel.Dock="Top">
        <r:RibbonTab x:Name="tab1" Header="Tab1">
            <r:RibbonGroup Header="Group1">
                <r:RibbonButton x:Name="button1" Label="Button 1" LargeImageSource="/Images/button1.png" />
                <r:RibbonButton x:Name="button2" Label="Button 2" LargeImageSource="/Images/button2.png"/>
                <r:RibbonButton x:Name="button3" Label="Button 3" LargeImageSource="/Images/Button3.png"/>
            </r:RibbonGroup>
            <r:RibbonGroup Header="Group2">
                <r:RibbonButton x:Name="button4" Label="Button 4" LargeImageSource="/Images/button4.png"/>
            </r:RibbonGroup>
            <r:RibbonGroup Header="Group 3">
                <r:RibbonMenuButton Label="Button 5" LargeImageSource="/Images/button5.png" >
                    <r:RibbonButton x:Name="button6" Label="Button 6" SmallImageSource="/Images/button6.png"/>
                </r:RibbonMenuButton>
                <r:RibbonMenuButton Label="Button 7" LargeImageSource="/Images/button7.png" >
                    <r:RibbonButton x:Name="button8" Label="Button 8" />
                </r:RibbonMenuButton>
            </r:RibbonGroup>
        </r:RibbonTab>
    </r:Ribbon>
    </DockPanel>
</r:RibbonWindow>

The only gotcha is that you need to update your view to inherit from RibbonWindow instead of Window.