Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top