我创建了许多自定义按钮(按钮左侧的图像,旁边的文字,垂直对齐)。 UI上的按钮显示正常,绑定到mvvmlight VM的代码也可以正常运行。
然而,当我点击一个按钮时,根本没有任何事情发生。
绑定看起来像这样
// at class level
private UIButton btnViewReceipts;
// in the create button method
this.btnViewReceipts = UICreation.CreateImageButton(new CGPoint(16, 300), "Images/receipt.png", "View Receipts");
// in the binding method
this.btnViewReceipts.SetCommand(Events.TouchUpInside, this.ViewModel.NavigateToReceiptsCommand);
调试器没有显示任何问题,并且在将按钮添加到视图之前执行绑定。
mvvmlight是否禁止绑定自定义按钮或我做错了什么?
答案 0 :(得分:0)
我之前在自定义按钮中遇到了一个问题,我在按钮上添加了一个UIView,触摸事件没有到达按钮。尝试将启用的用户交互设置为false或辞职到该视图的第一响应者