使用 caliburn.micro 时在表单中查找控件的最佳方法是什么?
使用 Caliburn.Micro 时,有没有一种好方法可以从 ViewModel 中查找表单中的命名控件?国际奥委会是否提供任何获取表格的方法?
Is there a good way to find a named control in a form from the ViewModel when using Caliburn.Micro? Does the IoC provide any way to get at the form?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在视图模型(
Screen
类型的一部分)中重写AttachView
或OnViewLoaded
,Caliburn.Micro 将视图传递给该模型,例如一个按钮控制:You can override
AttachView
orOnViewLoaded
in your view model (part of theScreen
type), which Caliburn.Micro passes the view to, e.g for a button control:您也可以从视图模型调用 GetView()。然后搜索该控件或按名称访问它。
You can call GetView() from the view model also. Then search for the control or access it by name.