Caliburn element convention

别来无恙 提交于 2019-12-10 17:34:27

问题


While trying to learn the source for GameLibrary sample application I saw a line like this:

ConventionManager.AddElementConvention<Rating>(Rating.ValueProperty, "Value", "ValueChanged");

Looked into the source of Caliburn but couldn't really understand what element conventions are.

Can someone describe briefly please?


回答1:


ConventionManager.AddElementConvention allows you to establish a set of "default" settings used by the convention system for each type element.

  • 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 a Rating control, we set up the binding against the ValueProperty.

  • 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.

  • 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.



来源:https://stackoverflow.com/questions/4227966/caliburn-element-convention

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!