2009-07-16 5 views
0

J'essaie d'utiliser le contrôle ruban Microsoft en utilisant C#. Tout va bien, mais je suis incapable de lier la commande via le RibbonCommand. Quelqu'un peut-il me donner un exemple de comment faire cela? Mon code actuel est:Commande de liaison pour le contrôle de ruban

  Ribbon rbn = new Ribbon(); 

      RibbonTab file = new RibbonTab(); 
      file.Name = "file"; 
      file.Label = "FILE"; 

      RibbonTab edit = new RibbonTab(); 
      edit.Name = "edit"; 
      edit.Label = "Edit"; 

      RibbonGroupPanel rbgp = new RibbonGroupPanel(); 
      RibbonGroup rbg = new RibbonGroup(); 

      RibbonButton rbtn = new RibbonButton(); 
      rbtn.Content = "New"; 

      RibbonCommand rcomnd = new RibbonCommand(); 

      rcomnd.LabelTitle = "NEW"; 
      rcomnd.ToolTipDescription = "THIS IS NEW"; 
      rcomnd.LargeImageSource = imgSource; 


      rcomnd.Execute(rbtn, rbtn); 

      rbtn.IsEnabled = true; 
      //rcomnd.SmallImageSource = imgSource; 

      rcomnd.CanExecute +=new CanExecuteRoutedEventHandler(rcomnd_CanExecute); 
      rcomnd.Executed +=new ExecutedRoutedEventHandler(rcomnd_Executed); 

      CommandBinding cmdb = new CommandBinding(ApplicationCommands.New); 
      cmdb.Command = ApplicationCommands.New; 

      cmdb.Executed +=new ExecutedRoutedEventHandler(cmdb_Executed); 
      CommandBind.Add(cmdb); 
      //rcomnd.Executed += new ExecutedRoutedEventHandler(OnAddNewEntry);*/ 

      rbtn.Click +=new System.Windows.RoutedEventHandler(rbtn_Click); 
      rbtn.Command = rcomnd; 

Mais les liaisons ne fonctionnent pas et le bouton n'est pas activé.

Répondre

1

Vérifiez la section this tutorial dans la section "Ajout de commandes". Il peut être bon de le lire dès le début.

Questions connexes