绑定到我在caliburn中的当前演示者,没有绑定约定 [英] binding to my current presenter in caliburn without binding convention

查看:84
本文介绍了绑定到我在caliburn中的当前演示者,没有绑定约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在caliburn中,当我使用绑定约定并命名内容控件 CurrentPresenter
时,框架会自动绑定到vm并找到相关视图。

in caliburn when i work with binding convention, and name a content control "CurrentPresenter" the framework automagically bind to the vm and locate the relevant view.

如果我手动执行此绑定,则不会找到视图。.
如果没有绑定约定(我的视图是用户控件),我如何实现此功能

if i do this binding manually the view is not located.. how might i achieve this ability without the binding convention (my view is a user control)

推荐答案

您应该绑定到View.Model附加属性,

You should bind to View.Model attached property, which:


  • 找出正确的属性表示虚拟机的视图

  • 将视图DataContext绑定到虚拟机

  • 在ContentControl的Content属性中推送视图

示例:

<!-- Caliburn v1.x -->
<ContentControl cal:View.Model="{Binding CurrentPresenter}" />

先前的代码段在Caliburn v1.x中有效,而在Caliburn v2和 Caliburn.Micro IPresesenterManager重命名为IConductor(接口成员也有所更改),因此绑定应为:

The previous snippet works in Caliburn v1.x, while in Caliburn v2 and Caliburn.Micro IPresesenterManager was renamed into IConductor (with some changes to interface members, too), so the binding should be:

<!-- Caliburn v2 & Caliburn.Micro -->
<ContentControl cal:View.Model="{Binding ActiveItem}" />

这篇关于绑定到我在caliburn中的当前演示者,没有绑定约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆