我正在使用 MVVMCross 开发一个应用程序,该应用程序使用 Storyboard作为 UI。在 Storyboard 中,我有一个带有静态单元格的 UITableView。如何将 ICommand(或 IMvxCommand)绑定(bind)到静态单元格上的单击或触摸?
目前我正在使用 UITapGestureRecognizer,但我认为这不是最合适的方式。
tableViewController.StaticCell.AddGestureRecognizer(new UITapGestureRecognizer(() =>
{
if (ViewModel.SomeCommand.CanExecute())
{
ViewModel.SomeCommand.Execute(null);
}
}));
最佳答案
您可以将 Tap 直接绑定(bind)到命令:
using MvvmCross.Binding.iOS.Views.Gestures;
set.Bind(this.SomeView.Tap()).For(vm => vm.Command)
关于xamarin - MVVMCross iOS 静态单元格命令绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37321205/