Caliburn.Micro:以编程方式创建和绑定视图
我目前正在 Caliburn.Micro 中尝试视图合成。我有一个工作示例,其中我通过“View.Model”附加属性路由将多个基于用户控件的视图注入到我的主 shell 中。到目前为止,一切都很好。
在我的应用程序中,我正在使用主要由 WinForms 和一些 WPF 组成的混合环境,因此没有可供 Caliburn 管理的 WPF“外壳”。我希望能够按需创建视图并将它们添加到我的 WinForms 应用程序中的占位符中。
我想知道如何使用 Caliburn 以编程方式创建视图(这将是包含子用户控件的用户控件),以便执行所有约定、模型绑定和子视图注入。
I am currently experimenting with view composition in Caliburn.Micro. I have a working example where I have multiple user control based views injected into my main shell via the "View.Model" attached property route. So far so good.
In my application proper I am working with a mixed environment of mainly WinForms, with some WPF, so there is no WPF "shell" for Caliburn to manage. I'd like to be able to create my views on demand and add them to placeholders in my WinForms app.
I would like to know how I go about creating a view (which will be a user control containing sub user controls) programmatically using Caliburn so that all conventions, model bindings and sub-view injection is carried out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一旦您拥有视图实例和相应的视图模型,Caliburn
ViewModelBinder
可用于启动手柄。调用 Bind 解析注入的视图并应用基于约定的绑定等:The Caliburn
ViewModelBinder
can be used to crank the handle once you have a view instance and a corresponding view-model. CallingBind
resolves injected views and applies convention based binding, etc:来自
BootstrapperBase.DisplayRootViewFor
的代码片段:Code snippet from
BootstrapperBase.DisplayRootViewFor
: