【发布时间】:2013-10-28 11:14:25
【问题描述】:
在我在 Mac 上的 Xamarin Studio 项目中,我使用来自 MvvmCross-Binaries 的 MvvmCross 版本 3.0.13,XS-iOS-Mac Release 程序集,并且我正在尝试将我的 CrossUI Dialog 基于 View 和对应的 ViewModel。具体来说,我在我的对话框视图中定义了Root,如下所示:
var bindings = this.CreateInlineBindingTarget<ViewModel>();
Root = new RootElement("New Connection") {
new Section {
new StringElement("Test")
.Bind(bindings, element => (object)element.SelectedCommand, vm => vm.TestConnection)
},
new Section {
new StringElement ("Add")
.Bind (bindings, element => element.Visible, vm => vm.CanAddConnection)
.Bind (bindings, element => (object)element.SelectedCommand, vm => vm.AddConnection)
}
};
在 ViewModel 中,如果测试成功,CanAddConnection 将通过 TestConnection 命令设置为 true。
当我运行它(在 iOS 模拟器中)并打开对话框时,会显示 Test 按钮并隐藏 Add 按钮(如预期的那样)。当我单击按钮并且测试成功时,Add 按钮未显示,而是在应用程序输出中收到此消息:
这是怎么发生的 - CurrentAttachedCell 是非 UITableView 的子项
为什么我的可见绑定不起作用?
据我所知,我没有在上游进行任何会导致代码中出现this failure 的代码自定义(但我可能会遗漏一些东西)。
如果我将CanAddConnection 绑定到另一个元素属性,例如Caption,布尔值会在视图中正确更新。
【问题讨论】:
标签: c# ios mvvmcross monotouch.dialog