我正在尝试使用来自Galasoft MVVMLight的RelayCommand执行我的CodeBehind中的RelayCommand。
MainPage.xaml.cs
public MainPage()
{
InitializeComponent();
DataContext = this;
MyCommand = new RelayCommand(Methode);
}
#region Commands
public RelayCommand MyCommand { get; private set; }
#endregion
private void Methode()
{
int i = 1;
}
MainPage.xaml:
<Button Command="{Binding MyCommand}"/>
很遗憾,命令没有触发/方法没有被调用。其他绑定的元素比如ImageSource都可以正常工作。