PropertyMetadata.Create PropertyMetadata.Create PropertyMetadata.Create PropertyMetadata.Create Method

Definition

Overloads

Create(CreateDefaultValueCallback) Create(CreateDefaultValueCallback) Create(CreateDefaultValueCallback) Create(CreateDefaultValueCallback)

Creates a PropertyMetadata value, specifying a callback that establishes a default value for a dependency property.

Create(CreateDefaultValueCallback, PropertyChangedCallback) Create(CreateDefaultValueCallback, PropertyChangedCallback) Create(CreateDefaultValueCallback, PropertyChangedCallback) Create(CreateDefaultValueCallback, PropertyChangedCallback)

Creates a PropertyMetadata value, specifying a callback that establishes a default value for a dependency property, and a property-changed callback.

Create(Object) Create(Object) Create(Object) Create(Object)

Creates a PropertyMetadata value, specifying a fixed default value for a dependency property.

Create(Object, PropertyChangedCallback) Create(Object, PropertyChangedCallback) Create(Object, PropertyChangedCallback) Create(Object, PropertyChangedCallback)

Creates a PropertyMetadata value, specifying a fixed default value for a dependency property, and a property-changed callback.

Create(CreateDefaultValueCallback) Create(CreateDefaultValueCallback) Create(CreateDefaultValueCallback) Create(CreateDefaultValueCallback)

Creates a PropertyMetadata value, specifying a callback that establishes a default value for a dependency property.

public : static PropertyMetadata Create(CreateDefaultValueCallback createDefaultValueCallback)
static PropertyMetadata Create(CreateDefaultValueCallback createDefaultValueCallback) const;
public static PropertyMetadata Create(CreateDefaultValueCallback createDefaultValueCallback)
Public Shared Function Create(createDefaultValueCallback As CreateDefaultValueCallback) As PropertyMetadata

Parameters

createDefaultValueCallback
CreateDefaultValueCallback CreateDefaultValueCallback

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

Returns

The newly created dependency property metadata.

Examples

This example shows pseudocode for using CreateDefaultValueCallback in a custom dependency property scenario. Specifically, this creates PropertyMetadata to be used in a DependencyProperty.Register call (not shown).

PropertyMetadata metadata = PropertyMetadata.Create(
    new CreateDefaultValueCallback(() =>
    {
        return new CustomClass() //a DependencyObject
        {
            CustomProperty1 = "default", //DependencyProperty of type String 
            CustomProperty2 = -1; //DependencyProperty of type Int32
        }
    })

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.

See also

Create(CreateDefaultValueCallback, PropertyChangedCallback) Create(CreateDefaultValueCallback, PropertyChangedCallback) Create(CreateDefaultValueCallback, PropertyChangedCallback) Create(CreateDefaultValueCallback, PropertyChangedCallback)

Creates a PropertyMetadata value, specifying a callback that establishes a default value for a dependency property, and a property-changed callback.

public : static PropertyMetadata Create(CreateDefaultValueCallback createDefaultValueCallback, PropertyChangedCallback propertyChangedCallback)
static PropertyMetadata Create(CreateDefaultValueCallback createDefaultValueCallback, PropertyChangedCallback propertyChangedCallback) const;
public static PropertyMetadata Create(CreateDefaultValueCallback createDefaultValueCallback, PropertyChangedCallback propertyChangedCallback)
Public Shared Function Create(createDefaultValueCallback As CreateDefaultValueCallback, propertyChangedCallback As PropertyChangedCallback) As PropertyMetadata

Parameters

createDefaultValueCallback
CreateDefaultValueCallback CreateDefaultValueCallback

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

propertyChangedCallback
PropertyChangedCallback PropertyChangedCallback

A reference to the callback method that is invoked by the property system when a dependency property value changes.

Returns

The newly created dependency property metadata.

See also

Create(Object) Create(Object) Create(Object) Create(Object)

Creates a PropertyMetadata value, specifying a fixed default value for a dependency property.

public : static PropertyMetadata Create(Platform::Object defaultValue)
static PropertyMetadata Create(winrt::Windows::Foundation::IInspectable defaultValue) const;
public static PropertyMetadata Create(Object defaultValue)
Public Shared Function Create(defaultValue As Object) As PropertyMetadata

Parameters

defaultValue
Object Object

The dependency property default value to apply.

Returns

The newly created dependency property metadata.

See also

Create(Object, PropertyChangedCallback) Create(Object, PropertyChangedCallback) Create(Object, PropertyChangedCallback) Create(Object, PropertyChangedCallback)

Creates a PropertyMetadata value, specifying a fixed default value for a dependency property, and a property-changed callback.

public : static PropertyMetadata Create(Platform::Object defaultValue, PropertyChangedCallback propertyChangedCallback)
static PropertyMetadata Create(winrt::Windows::Foundation::IInspectable defaultValue, PropertyChangedCallback propertyChangedCallback) const;
public static PropertyMetadata Create(Object defaultValue, PropertyChangedCallback propertyChangedCallback)
Public Shared Function Create(defaultValue As Object, propertyChangedCallback As PropertyChangedCallback) As PropertyMetadata

Parameters

defaultValue
Object Object

The dependency property default value to apply.

propertyChangedCallback
PropertyChangedCallback PropertyChangedCallback

A reference to the callback method that is invoked by the property system when a dependency property value changes.

Returns

The newly created dependency property metadata.

See also