开发者

Caliburn element convention

开发者 https://www.devze.com 2023-01-26 13:20 出处:网络
While trying to learn the source fo开发者_StackOverflowr GameLibrary sample application I saw a line like this:

While trying to learn the source fo开发者_StackOverflowr 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号