Search code examples
wpfxamlcontrolsribbon

How to enable ribbon menu?


<r:RibbonWindow.Resources>
    <ResourceDictionary>

        <!--Ribbon Commands-->
        <r:RibbonCommand x:Key="cmdPrint" CanExecute="RibbonCommand_CanExecute_Print" LabelTitle="Print" LabelDescription="Print" ToolTipTitle="Help" ToolTipDescription="This is used to Print" SmallImageSource="Images\printIcon.png" LargeImageSource="Images\printIcon.png" />
        <r:RibbonCommand x:Key="cmdExit" CanExecute="RibbonCommand_CanExecute_Close" LabelTitle="Close" LabelDescription="Close" ToolTipTitle="Help" ToolTipDescription="Close Application" SmallImageSource="Images\exitIcon.png" LargeImageSource="Images\exitIcon.png" />
        <r:RibbonCommand x:Key="cmdHelp" CanExecute="RibbonCommand_CanExecute_Help" LabelTitle="About" LabelDescription="Help" ToolTipTitle="Help" ToolTipDescription="About Application" SmallImageSource="Images\vdiWorksIcon.png" LargeImageSource="Images\vdiWorksIcon.png" />

        <!--Theme-->
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml" />
        </ResourceDictionary.MergedDictionaries>

    </ResourceDictionary>
</r:RibbonWindow.Resources>

<!--Root Grid-->
<Grid x:Name="LayoutRoot">




    <r:Ribbon Title="Protocol Inspector" x:Name="ribbon" BorderBrush="Orange">
        <r:Ribbon.SelectedTab>
            <r:RibbonTab/>
        </r:Ribbon.SelectedTab>

        <!--Quick Access Toolbar-->
        <r:Ribbon.QuickAccessToolBar>
            <r:RibbonQuickAccessToolBar>
                <r:RibbonButton Command="{StaticResource cmdExit}" />
                <r:RibbonButton Command="{StaticResource cmdPrint}" />
                <r:RibbonButton Command="{StaticResource cmdHelp}"/>
            </r:RibbonQuickAccessToolBar>
        </r:Ribbon.QuickAccessToolBar>

        <r:Ribbon.ApplicationMenu>                
            <r:RibbonApplicationMenu IsEnabled="True" >
              <r:RibbonApplicationMenu.Command>
                    <r:RibbonCommand Executed="RibbonCommand_Executed" SmallImageSource="Images\VdiworksIcon.png" LargeImageSource="Images\VdiworksIcon.png" />
                </r:RibbonApplicationMenu.Command>

                <r:RibbonApplicationMenuItem Command="{StaticResource cmdPrint}" />
                <r:RibbonApplicationMenuItem Command="{StaticResource cmdExit}" />
                <r:RibbonApplicationMenuItem Command="{StaticResource cmdHelp}" />

            </r:RibbonApplicationMenu>
        </r:Ribbon.ApplicationMenu>
        <r:RibbonTab x:Name="HomeTab" Label="Home" IsSelected="True">
            <r:RibbonGroup Name="FileGroup">
                <r:RibbonGroup.Command>
                    <r:RibbonCommand LabelTitle="Home" />
                </r:RibbonGroup.Command>
                <r:RibbonButton Name="menuExit" Content="Exit" Command="{StaticResource cmdExit}"/>
                <r:RibbonButton Name="menuPrint" Content="Print" Command="{StaticResource cmdPrint}"/>
            </r:RibbonGroup>
        </r:RibbonTab>
        <r:RibbonTab x:Name="HelpTab" Label="Help">
            <r:RibbonGroup Name="HelpGroup">
                <r:RibbonGroup.Command>
                    <r:RibbonCommand LabelTitle="Help" />
                </r:RibbonGroup.Command>

                <r:RibbonButton Name="menuAbout" Content="About" Command="{StaticResource cmdHelp}"/>
            </r:RibbonGroup>
        </r:RibbonTab>
    </r:Ribbon>

Menu options are not enabled, they are disabled.


Solution

  • 100% working Correct Answer

    <r:RibbonWindow.Resources>
        <ResourceDictionary>
    
            <r:RibbonCommand Executed="RibbonCommand_Executed" x:Key="cmdPrint" LabelTitle="Print" LabelDescription="Print" ToolTipTitle="Help" ToolTipDescription="This is used to Print" SmallImageSource="Images\printIcon.png" LargeImageSource="Images\printIcon.png" />
            <r:RibbonCommand Executed="RibbonCommand_Executed" x:Key="cmdExit" LabelTitle="Close" LabelDescription="Close" ToolTipTitle="Help" ToolTipDescription="Close Application" SmallImageSource="Images\exitIcon.png" LargeImageSource="Images\exitIcon.png" />
            <r:RibbonCommand Executed="RibbonCommand_Executed" x:Key="cmdHelp" LabelTitle="About" LabelDescription="Help" ToolTipTitle="Help" ToolTipDescription="About Application" SmallImageSource="Images\ICON.png" LargeImageSource="Images\ICON.png" />
            <r:RibbonCommand x:Key="testCmd" Executed="RibbonCommand_Executed" LabelTitle="Test Command" ToolTipDescription="test command" SmallImageSource="Images\ICON.png" LargeImageSource="Images\ICON.png"/>
    
            <!--Theme-->
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml" />
            </ResourceDictionary.MergedDictionaries>
    
        </ResourceDictionary>
    </r:RibbonWindow.Resources>