If Window2.Execute() is activated by pressing input gesture (F4), e.Parameter is null. If activated by mouse click, parameter is as expected ("param").
[Modified at 02/14/2009 06:26 AM]
<Window x:Class="WpfApplication1.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="600" Width="600" xmlns:apr="clr-namespace:ActiproSoftware.Windows.Controls.Ribbon;assembly=ActiproSoftware.Ribbon.WPF30" xmlns:apc="clr-namespace:ActiproSoftware.Windows.Controls.Ribbon.Controls;assembly=ActiproSoftware.Ribbon.WPF30" xmlns:aps="clr-namespace:ActiproSoftware.Windows.DocumentManagement;assembly=ActiproSoftware.Shared.WPF30">
<StackPanel>
<apr:Ribbon Name="ribbon" DockPanel.Dock="Top">
<apr:Ribbon.ApplicationMenu>
<apc:ApplicationMenu KeyTipAccessText="">
<apc:ApplicationMenu.AdditionalContent>
<apc:RecentDocumentMenu Label="Recent Projects">
<aps:RecentDocumentManager x:Name="recentDocumentManager" />
</apc:RecentDocumentMenu>
</apc:ApplicationMenu.AdditionalContent>
</apc:ApplicationMenu>
</apr:Ribbon.ApplicationMenu>
</apr:Ribbon>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ActiproSoftware.Windows.Controls.Ribbon.Controls;
using Button = ActiproSoftware.Windows.Controls.Ribbon.Controls.Button;
using ActiproSoftware.Windows.Controls.Ribbon.Input;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for Window2.xaml
/// </summary>
public partial class Window2 : Window
{
public Window2()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Window2_Loaded);
}
void Window2_Loaded(object sender, RoutedEventArgs e)
{
ribbon.Tabs.Add(new Tab());
ribbon.Tabs[0].Items.Add(new Group());
RibbonCommand command = new RibbonCommand("button command", GetType());
command.InputGestures.Add(new KeyGesture(Key.F4, ModifierKeys.None));
Button button = new Button();
button.CommandParameter = "param";
button.Label = "button";
ribbon.Tabs[0].Items[0].Items.Add(button);
button.Command = command;
CommandBinding binding = new CommandBinding(command, Execute);
CommandBindings.Add(binding);
}
void Execute(object sender, ExecutedRoutedEventArgs e)
{
string x = (string) e.Parameter;
}
}
}