Version

CommandParameter Property (MenuTool)

Gets or sets the parameter to pass to the Command property.
Syntax
'Declaration
 
Public Property CommandParameter As Object
public object CommandParameter {get; set;}
Example
MenuTool CommandParameter

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

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also