Caliburn元素约定 [英] Caliburn element convention
问题描述
在尝试学习GameLibrary示例应用程序的源代码时,我看到了这样的一行:
While trying to learn the source for GameLibrary sample application I saw a line like this:
ConventionManager.AddElementConvention<Rating>(Rating.ValueProperty, "Value", "ValueChanged");
研究了Caliburn的来源,但无法真正理解什么是元素约定。
Looked into the source of Caliburn but couldn't really understand what element conventions are.
有人可以简短描述吗?
推荐答案
ConventionManager。 AddElementConvention
允许您为每个类型元素建立约定系统使用的一组默认设置。
ConventionManager.AddElementConvention
allows you to establish a set of "default" settings used by the convention system for each type element.
-
在上述情况下,
Rating.ValueProperty
的第一个参数值告诉约定系统该元素的默认可绑定属性是什么。因此,如果在Rating
控件上有约定匹配,我们将对ValueProperty
设置绑定。
In the case mentioned above, the first parameter value of
Rating.ValueProperty
tells the convention system what the default bindable property is for the element. So, if we have a convention match on aRating
control, we set up the binding against theValueProperty
.
第二个参数表示要在Action绑定中使用的默认属性。因此,如果使用 ElementName
创建的动作绑定指向 Rating
控件,但不指定该属性,我们回到 Value
属性。
The second parameter represents the default property to be used in Action bindings. So, if you create an action binding with an ElementName
that points to a Rating
control, but do not specify the property, we fall back to the Value
property.
最后,thrid参数代表默认事件控制。因此,如果我们将动作附加到评分控件上,但未指定触发该动作的事件,则系统将退回到 ValueChanged
事件。
Finally, the thrid parameter represents the default event for the control. So, if we attach an action to a rating control, but don't specify the event to trigger that action, the system will fall back to the ValueChanged
event.
这些元素约定允许开发人员在各种情况下提供或多或少的信息,从而允许框架填充缺少的详细信息为适当。
These element conventions allow the developer to supply as much or as little information in a variety of situations, allowing the framework to fill in the missing details as approptiate.
这篇关于Caliburn元素约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!