views:

649

answers:

2
<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>

BUT MENU OPTIONS ARE NOT ENABLED ... THEY ARE DISABLED ... KINDLY HELP ME

A: 

Instead of specifying CanExecute and Executed event handlers for the individual commands in the Resources tag, try specifying them as CommandBindings

<r:Ribbon Title="Protocol Inspector" x:Name="ribbon" BorderBrush="Orange">
    <r:Ribbon.CommandBindings>
        <CommandBinding Command="{StaticResource cmdExit}" 
            CanExecute="cmdExit_CanExecute"
            Executed="cmdExit_Executed" />
    </r:Ribbon.CommandBindings>
...
Trainee4Life
@Aizaz: If you need to ask that question, then you need to read a beginners guide to WPF I'm afraid.
Noldorin
The CommandBindings need to be put in the <r:Ribbon> tag. I edited my answer to reflect this more explicitly.
Trainee4Life
+1  A: 

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>
Aizaz