2009-10-16 10 views
-1
<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> 

Les options de menu ne sont pas activées, elles sont désactivées.Comment activer le menu du ruban?

Répondre

1

100% de travail réponse correcte

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

lieu de spécifier CanExecute et gestionnaires d'événements Exécuté pour les commandes individuelles dans la balise de ressources, essayez de les spécifier comme 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> 
... 
+0

@Aizaz: Si vous avez besoin de poser cette question, alors vous devez lire un guide des débutants à WPF j'ai peur. – Noldorin

+0

Les CommandBindings doivent être placés dans la balise . J'ai édité ma réponse pour refléter ceci plus explicitement. – Trainee4Life

Questions connexes