在我的Xamarin iOS項目中,我想用一個參數將一個按鈕綁定到一個ICommand。帶參數的綁定命令
查看:
var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(Button1).To(vm => vm.EditCommand).WithConversion(new MvxCommandParameterValueConverter(), 1);
set.Apply();
視圖模型:
private readonly ICommand editCommand;
public MyViewModel()
{
editCommand = new BaseMvxCommand<int>(DoEditPhoto);
}
public ICommand EditCommand { get { return editCommand; } }
private void DoEditPhoto(int imageNum)
{
// enter code here
}
當我按下按鈕,我不能夠執行DoEditPhoto()
。我以不正確的方式綁定?誰能幫我嗎?
的[MvvMCross綁定參數命令(在C#代碼)](可能的複製http://stackoverflow.com/questions/17492742/mvvmcross-bind-command:爲此,您可以在您的鏈條,而不是使用
CommandParameter
-with-parameter-in-c-sharp-code) – Cheesebaron什麼是BaseMvxCommand? – Cheesebaron
BaseMvxCommnad是MvxCommand類。這個問題與該問題不重複,因爲該問題的答案建議使用我已經使用的命令參數,但它不起作用。 – TheDeveloper