Setting Metadata to Influence Layout
When a property of an element has an effect on the size of the element or the ordering of its children, appropriate metadata has to be added to its declaration as a dependency property to trigger the appropriate stage of the layout process.
-
AffectsLayout: Specifies that the property triggers a change in the ordering of child elements. Used to trigger a layout update whenever the property changes.
-
InvalidatesLayout: Used in the old layout system to invalidate the layout of an element when the property value changes.
-
AffectMeasure: Specifies that the property triggers a change in the size of the element. Used to trigger a layout update whenever the property changes.
-
AffectsArrange: Equivalent to AffectsLayout.
The example code below shows a RightToLeft dependency property with the AffectsLayout and InvalidatesLayout included in the call to RadPropertyRegister.
Adding metadata
public static RadProperty RTLProperty = RadProperty.Register(
"RTL", typeof(bool), typeof(BoxLayout), new RadElementPropertyMetadata(
false, ElementPropertyOptions.AffectsLayout | ElementPropertyOptions.InvalidatesLayout));
The metadata is consumed when the RadElement OnPropertyChanged method is fired, the RadElement RadPropertyMetaData is evaluated and methods are called based on the type of metadata present.