バージョン

CommandParameter プロパティ (MenuTool)

Command プロパティに渡すためのパラメーターを取得または設定します。
シンタックス
'宣言
 
Public Property CommandParameter As Object
public object CommandParameter {get; set;}
使用例
Dim logText As TextBox 
...
Dim menuTool As New MenuTool() 
menuTool.Caption = "Menu Tool" 
menuTool.ButtonType = MenuToolButtonType.SegmentedState 
menuTool.SmallImage = getImageSource("/Images/icons/Ribbon/QuickStyles_16x16.png") 
menuTool.LargeImage = getImageSource("/Images/icons/Ribbon/QuickStyles_32x32.png") 
menuTool.KeyTipForSegmentedButton = "MT" 
menuTool.ShouldDisplayGalleryPreview = True 

menuTool.Items.Add("Menu Item 1") 
menuTool.Items.Add("Menu Item 2") 

Dim OpenCmdBinding As New CommandBinding(ApplicationCommands.Open, OpenCmdExecuted, OpenCmdCanExecute) 

Me.logText.CommandBindings.Add(OpenCmdBinding) 

menuTool.Command = ApplicationCommands.Open 

menuTool.CommandTarget = Me.logText 
menuTool.CommandParameter = "Command parameter..." 

' Execute 
Private Sub OpenCmdExecuted(ByVal target As Object, ByVal e As ExecutedRoutedEventArgs) 
    Dim command As String, targetobj As String 
    command = DirectCast(e.Command, RoutedCommand).Name 
    targetobj = DirectCast(target, FrameworkElement).Name 
    Debug.Write("The " + command + " command has been invoked on target object: " + targetobj + ". Parameter: " + e.Parameter) 
End Sub 
' Can execute 
Private Sub OpenCmdCanExecute(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs) 
    e.CanExecute = True 
End Sub
TextBox logText;
...
MenuTool menuTool = new MenuTool();
menuTool.Caption = "Menu Tool";
menuTool.ButtonType = MenuToolButtonType.SegmentedState;
menuTool.SmallImage= getImageSource("/Images/icons/Ribbon/QuickStyles_16x16.png");
menuTool.LargeImage= getImageSource("/Images/icons/Ribbon/QuickStyles_32x32.png");
menuTool.KeyTipForSegmentedButton="MT";
menuTool.ShouldDisplayGalleryPreview = true;

menuTool.Items.Add("Menu Item 1");
menuTool.Items.Add("Menu Item 2");

CommandBinding OpenCmdBinding = new CommandBinding(
    ApplicationCommands.Open,
    OpenCmdExecuted,
    OpenCmdCanExecute);

this.logText.CommandBindings.Add(OpenCmdBinding);

menuTool.Command = ApplicationCommands.Open;//ApplicationCommands.Open;
menuTool.CommandTarget = this.logText;
menuTool.CommandParameter = "Command parameter...";

// Execute
void OpenCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
    string command, targetobj;
    command = ((RoutedCommand)e.Command).Name;
    targetobj = ((FrameworkElement)target).Name;
    Debug.Write("The " + command + " command has been invoked on target object: " + targetobj + ". Parameter: " + e.Parameter);
}
// Can execute 
void OpenCmdCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
    e.CanExecute = true;
}
<igRibbon:MenuTool
    
Caption= "Menu Tool"
    ButtonType= "Segmented" 
    SmallImage= "Images\icons\Ribbon\QuickStyles_16x16.png" 
    
LargeImage= "Images\icons\Ribbon\QuickStyles_32x32.png" 
    
Command= "Open"
 
   CommandTarget="{Binding ElementName=textBox}"
    
CommandParameter="CommandParameter..."
    
>
    
<TextBlock Text="Menu Item 1"/>
    
<TextBlock Text="Menu Item 2"/>
</igRibbon:MenuTool>
参照