Windows.UI.Xaml.PropertyMetadata.CreateDefaultValueCallback

July 6, 2022 ยท View on GitHub

-description

Gets a reference to the callback method that provides a default property value.

-property-value

A reference to the callback method that provides a default property value.

-remarks

Use a CreateDefaultValueCallback instead of a fixed constant default value in any case where the default value of a dependency property might be thread-bound. The CreateDefaultValueCallback becomes a factory for default values whenever there is a need to get default values of properties on threads other than the main UI thread.

In order to establish a CreateDefaultValueCallback pattern for a dependency property, use one of the static Create methods instead of using the PropertyMetadata constructor when you define the metadata for the property. That metadata is submitted to the Register call. For more info, see Custom dependency properties. As with a property-changed callback, the CreateDefaultValueCallback method should be a static method of the type that registers the dependency property. The method does not have to be public.

-examples

-see-also

DependencyProperty.Register, Custom dependency properties