First of all you need a class that extends ICommand. You can use this:
public class DelegateCommand : ICommand
{
private readonly Action<object> executeMethod = null;
private readonly Func<object, bool> canExecuteMethod = null;
public event EventHandler CanExecuteChanged
{
add { return; }
remove { return; }
}
public DelegateCommand(Action<object> executeMethod, Func<object, bool> canExecuteMethod)
{
this.executeMethod = executeMethod;
this.canExecuteMethod = canExecuteMethod;
}
public bool CanExecute(object parameter)
{
if (canExecuteMethod == null) return true;
return this.canExecuteMethod(parameter);
}
public void Execute(object parameter)
{
if (executeMethod == null) return;
this.executeMethod(parameter);
}
}
Then, in your class Type1 you have to declare this:
public DelegateCommand OnCommand1a {get; private set;}
and set it in your Type1 constructor in this way:
OnCommand1a = new DelegateCommand(c => Cmd1a(), null);
where Cmd1a is:
private void Cmd1a()
{
//your code here
}
Finally, in your xaml:
Command="{Binding Path=OnCommand1a}"