I've an issue with adding a UIcommand to the button.
I tried to add command like I did before with .Click action method, like "button.Click += CommandBinding_button_Executed;", but failed.
<!--Declaration in XAML-->
<Window.Resources>
<RoutedUICommand x:Key="BtnCmd" Text="BtnCmd">
<RoutedUICommand.InputGestures>
<KeyGesture>CTRL+R</KeyGesture>
</RoutedUICommand.InputGestures>
</RoutedUICommand>
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource BtnCmd}"
Executed="CommandBinding_BtnCmd_Executed"/>
</Window.CommandBindings>
public partial class MainWindow : Window
{
//Using in C#
Button button = new Button;
button.Command += CommandBinding_button_Executed; //An issue
//Puts button in form
Grid.SetRow(button, 0);
Grid.SetColumn(button, 0);
grid.Children.Add(button);
private void CommandBinding_BtnCmd_Executed(object sender, ExecutedRoutedEventArgs e)
{
//some code
}
}
I expected that it should add an execution method of that command, but there's an error type not delegate of ICommand.