Caliburn 是否需要给定对象的元素约定才能将其 ViewModel 实例映射到 View 实例?
我正在尝试将 ViewModel 中的 Canvas 对象映射到视图中的 Canvas 对象。
但是,当我运行时,出现“CompositionException 未由用户代码处理”错误。在 ViewModel 中注释掉我的 Canvas 对象可以防止出现错误,所以我猜测 Caliburn 正在尝试映射它并引发错误。
I'm trying to map a Canvas object in my ViewModel to a Canvas object in my View.
However I get a "CompositionException was unhandled by user code" error when I run. Commenting out my Canvas object in the ViewModel prevents the error, so I'm guessing Caliburn is trying to map it and raising the error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ViewModel 中的 Canvas 对象到 View 中的 Canvas 对象?
我不认为 Caliburn 会这么做。 Caliburn 希望您将属性/方法映射到页面上的控件。
So:ViewModel
View:
此代码的作用是将 SelectedModel 链接到 ListBox 的“SelectedItem”属性,将 Models 属性链接到“ItemsSource”属性,并连接到 CheckedChange 事件,以便在用户单击时更改 SelectedItem在它上面。
Caliburn 有一个很棒的文档部分,非常值得浏览他的示例: Caliburn 微文档
A Canvas object in your ViewModel to a Canvas object in your View?
I don't think Caliburn will do that. Caliburn is expecting you to map your properties/methods to controls on the page.
So:ViewModel
View:
What this code does is links the SelectedModel up to the "SelectedItem" property of the ListBox, the Models property up to the "ItemsSource" property and wires in the CheckedChange event so that the SelectedItem is changed when the user clicks on it.
There's a great documentation section in Caliburn, it's well worth going through his examples: Caliburn Micro Docs