FrameworkPropertyMetadata Constructors

Definition

Initializes a new instance of the FrameworkPropertyMetadata class.

Overloads

FrameworkPropertyMetadata()

Initializes a new instance of the FrameworkPropertyMetadata class.

FrameworkPropertyMetadata(Object)

Initializes a new instance of the FrameworkPropertyMetadata class with the specified default value.

FrameworkPropertyMetadata(PropertyChangedCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the specified PropertyChangedCallback callback.

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework-level metadata options.

FrameworkPropertyMetadata(Object, PropertyChangedCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and specified PropertyChangedCallback callback.

FrameworkPropertyMetadata(PropertyChangedCallback, CoerceValueCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the specified callbacks.

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, and specified PropertyChangedCallback callback.

FrameworkPropertyMetadata(Object, PropertyChangedCallback, CoerceValueCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and specified callbacks.

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback, CoerceValueCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, and specified callbacks.

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback, CoerceValueCallback, Boolean)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, specified callbacks, and a Boolean that can be used to prevent animation of the property.

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback, CoerceValueCallback, Boolean, UpdateSourceTrigger)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, specified callbacks, a Boolean that can be used to prevent animation of the property, and a data-binding update trigger default.

FrameworkPropertyMetadata()

Initializes a new instance of the FrameworkPropertyMetadata class.

public:
 FrameworkPropertyMetadata();
public FrameworkPropertyMetadata ();
Public Sub New ()

Remarks

This signature initializes all values of FrameworkPropertyMetadata to their property defaults. DefaultValue will be null, and the various FrameworkPropertyMetadata Boolean properties will be false.

See also

FrameworkPropertyMetadata(Object)

Initializes a new instance of the FrameworkPropertyMetadata class with the specified default value.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue);
public FrameworkPropertyMetadata (object defaultValue);
new System.Windows.FrameworkPropertyMetadata : obj -> System.Windows.FrameworkPropertyMetadata
Public Sub New (defaultValue As Object)

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a value of a specific type.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(Double.NaN);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

See also

FrameworkPropertyMetadata(PropertyChangedCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the specified PropertyChangedCallback callback.

public:
 FrameworkPropertyMetadata(System::Windows::PropertyChangedCallback ^ propertyChangedCallback);
public FrameworkPropertyMetadata (System.Windows.PropertyChangedCallback propertyChangedCallback);
new System.Windows.FrameworkPropertyMetadata : System.Windows.PropertyChangedCallback -> System.Windows.FrameworkPropertyMetadata

Parameters

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnCurrentReadingChanged));

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework-level metadata options.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::FrameworkPropertyMetadataOptions flags);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.FrameworkPropertyMetadataOptions flags);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.FrameworkPropertyMetadataOptions -> System.Windows.FrameworkPropertyMetadata
Public Sub New (defaultValue As Object, flags As FrameworkPropertyMetadataOptions)

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a value of a specific type.

flags
FrameworkPropertyMetadataOptions

The metadata option flags (a combination of FrameworkPropertyMetadataOptions values). These options specify characteristics of the dependency property that interact with systems such as layout or data binding.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    (FrameworkPropertyMetadataOptions.AffectsRender |
      FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

Values marked as set flags in the flags parameter will set the Boolean value of FrameworkPropertyMetadata properties that match that FrameworkPropertyMetadataOptions flag's name to true. You can subsequently change the values of the properties in the metadata, as long as the metadata has not yet been applied to a specific property system operation.

See also

FrameworkPropertyMetadata(Object, PropertyChangedCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and specified PropertyChangedCallback callback.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::PropertyChangedCallback ^ propertyChangedCallback);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.PropertyChangedCallback propertyChangedCallback);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.PropertyChangedCallback -> System.Windows.FrameworkPropertyMetadata

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a value of a specific type.

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    new PropertyChangedCallback(OnCurrentReadingChanged)
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

See also

FrameworkPropertyMetadata(PropertyChangedCallback, CoerceValueCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the specified callbacks.

public:
 FrameworkPropertyMetadata(System::Windows::PropertyChangedCallback ^ propertyChangedCallback, System::Windows::CoerceValueCallback ^ coerceValueCallback);
public FrameworkPropertyMetadata (System.Windows.PropertyChangedCallback propertyChangedCallback, System.Windows.CoerceValueCallback coerceValueCallback);
new System.Windows.FrameworkPropertyMetadata : System.Windows.PropertyChangedCallback * System.Windows.CoerceValueCallback -> System.Windows.FrameworkPropertyMetadata

Parameters

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

coerceValueCallback
CoerceValueCallback

A reference to a handler implementation will be called whenever the property system calls CoerceValue(DependencyProperty) for this dependency property.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    new PropertyChangedCallback(OnCurrentReadingChanged),
    new CoerceValueCallback(CoerceCurrentReading)
);

Remarks

This implementation calls a base initializer and then adds the coerceValueCallback by setting the property on the base instance.

See also

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, and specified PropertyChangedCallback callback.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::FrameworkPropertyMetadataOptions flags, System::Windows::PropertyChangedCallback ^ propertyChangedCallback);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.FrameworkPropertyMetadataOptions flags, System.Windows.PropertyChangedCallback propertyChangedCallback);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.FrameworkPropertyMetadataOptions * System.Windows.PropertyChangedCallback -> System.Windows.FrameworkPropertyMetadata

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a value of a specific type.

flags
FrameworkPropertyMetadataOptions

The metadata option flags (a combination of FrameworkPropertyMetadataOptions values). These options specify characteristics of the dependency property that interact with systems such as layout or data binding.

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    (FrameworkPropertyMetadataOptions.AffectsRender |
      FrameworkPropertyMetadataOptions.BindsTwoWayByDefault),
    new PropertyChangedCallback(OnCurrentReadingChanged)
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

Values marked as set flags in the flags parameter will set the Boolean value of FrameworkPropertyMetadata properties that match that FrameworkPropertyMetadataOptions flag's name to true. You can still change the values of the properties in the metadata, as long as the metadata has not yet been applied to a specific property system operation.

See also

FrameworkPropertyMetadata(Object, PropertyChangedCallback, CoerceValueCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and specified callbacks.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::PropertyChangedCallback ^ propertyChangedCallback, System::Windows::CoerceValueCallback ^ coerceValueCallback);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.PropertyChangedCallback propertyChangedCallback, System.Windows.CoerceValueCallback coerceValueCallback);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.PropertyChangedCallback * System.Windows.CoerceValueCallback -> System.Windows.FrameworkPropertyMetadata

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a specific type.

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

coerceValueCallback
CoerceValueCallback

A reference to a handler implementation that will be called whenever the property system calls CoerceValue(DependencyProperty) for this dependency property.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    new PropertyChangedCallback(OnCurrentReadingChanged),
    new CoerceValueCallback(CoerceCurrentReading)
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

See also

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback, CoerceValueCallback)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, and specified callbacks.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::FrameworkPropertyMetadataOptions flags, System::Windows::PropertyChangedCallback ^ propertyChangedCallback, System::Windows::CoerceValueCallback ^ coerceValueCallback);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.FrameworkPropertyMetadataOptions flags, System.Windows.PropertyChangedCallback propertyChangedCallback, System.Windows.CoerceValueCallback coerceValueCallback);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.FrameworkPropertyMetadataOptions * System.Windows.PropertyChangedCallback * System.Windows.CoerceValueCallback -> System.Windows.FrameworkPropertyMetadata

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a specific type.

flags
FrameworkPropertyMetadataOptions

The metadata option flags (a combination of FrameworkPropertyMetadataOptions values). These options specify characteristics of the dependency property that interact with systems such as layout or data binding.

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

coerceValueCallback
CoerceValueCallback

A reference to a handler implementation that will be called whenever the property system calls CoerceValue(DependencyProperty) against this property.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    (FrameworkPropertyMetadataOptions.AffectsRender |
      FrameworkPropertyMetadataOptions.BindsTwoWayByDefault),
    new PropertyChangedCallback(OnCurrentReadingChanged),
    new CoerceValueCallback(CoerceCurrentReading)
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

Values marked as set flags in the flags parameter will set the Boolean value of FrameworkPropertyMetadata properties that match that FrameworkPropertyMetadataOptions flag's name to true. You can still change the values of the properties in the metadata, as long as the metadata has not yet been applied to a specific property system operation.

See also

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback, CoerceValueCallback, Boolean)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, specified callbacks, and a Boolean that can be used to prevent animation of the property.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::FrameworkPropertyMetadataOptions flags, System::Windows::PropertyChangedCallback ^ propertyChangedCallback, System::Windows::CoerceValueCallback ^ coerceValueCallback, bool isAnimationProhibited);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.FrameworkPropertyMetadataOptions flags, System.Windows.PropertyChangedCallback propertyChangedCallback, System.Windows.CoerceValueCallback coerceValueCallback, bool isAnimationProhibited);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.FrameworkPropertyMetadataOptions * System.Windows.PropertyChangedCallback * System.Windows.CoerceValueCallback * bool -> System.Windows.FrameworkPropertyMetadata

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a specific type.

flags
FrameworkPropertyMetadataOptions

The metadata option flags (a combination of FrameworkPropertyMetadataOptions values). These options specify characteristics of the dependency property that interact with systems such as layout or data binding.

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

coerceValueCallback
CoerceValueCallback

A reference to a handler implementation that will be called whenever the property system calls CoerceValue(DependencyProperty) on this dependency property.

isAnimationProhibited
Boolean

true to prevent the property system from animating the property that this metadata is applied to. Such properties will raise a run-time exception originating from the property system if animations of them are attempted. false to permit animating the property. The default is false.

Exceptions

defaultValue is set to UnsetValue.

Examples

The following example calls this constructor signature:

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    (FrameworkPropertyMetadataOptions.AffectsRender |
      FrameworkPropertyMetadataOptions.BindsTwoWayByDefault),
    new PropertyChangedCallback(OnCurrentReadingChanged),
    new CoerceValueCallback(CoerceCurrentReading),
    true //Animation prohibited
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

The isAnimationProhibited parameter sets the initial value of the IsAnimationProhibited property declared by the immediate base UIPropertyMetadata class.

Values marked as set flags in the flags parameter will set the Boolean value of FrameworkPropertyMetadata properties that match that FrameworkPropertyMetadataOptions flag's name to true. You can still change the values of the properties in the metadata, as long as the metadata has not yet been applied to a specific property system operation.

See also

FrameworkPropertyMetadata(Object, FrameworkPropertyMetadataOptions, PropertyChangedCallback, CoerceValueCallback, Boolean, UpdateSourceTrigger)

Initializes a new instance of the FrameworkPropertyMetadata class with the provided default value and framework metadata options, specified callbacks, a Boolean that can be used to prevent animation of the property, and a data-binding update trigger default.

public:
 FrameworkPropertyMetadata(System::Object ^ defaultValue, System::Windows::FrameworkPropertyMetadataOptions flags, System::Windows::PropertyChangedCallback ^ propertyChangedCallback, System::Windows::CoerceValueCallback ^ coerceValueCallback, bool isAnimationProhibited, System::Windows::Data::UpdateSourceTrigger defaultUpdateSourceTrigger);
public FrameworkPropertyMetadata (object defaultValue, System.Windows.FrameworkPropertyMetadataOptions flags, System.Windows.PropertyChangedCallback propertyChangedCallback, System.Windows.CoerceValueCallback coerceValueCallback, bool isAnimationProhibited, System.Windows.Data.UpdateSourceTrigger defaultUpdateSourceTrigger);
new System.Windows.FrameworkPropertyMetadata : obj * System.Windows.FrameworkPropertyMetadataOptions * System.Windows.PropertyChangedCallback * System.Windows.CoerceValueCallback * bool * System.Windows.Data.UpdateSourceTrigger -> System.Windows.FrameworkPropertyMetadata

Parameters

defaultValue
Object

The default value of the dependency property, usually provided as a specific type.

flags
FrameworkPropertyMetadataOptions

The metadata option flags (a combination of FrameworkPropertyMetadataOptions values). These options specify characteristics of the dependency property that interact with systems such as layout or data binding.

propertyChangedCallback
PropertyChangedCallback

A reference to a handler implementation that the property system will call whenever the effective value of the property changes.

coerceValueCallback
CoerceValueCallback

A reference to a handler implementation that will be called whenever the property system calls CoerceValue(DependencyProperty) against this property.

isAnimationProhibited
Boolean

true to prevent the property system from animating the property that this metadata is applied to. Such properties will raise a run-time exception originating from the property system if animations of them are attempted. The default is false.

defaultUpdateSourceTrigger
UpdateSourceTrigger

The UpdateSourceTrigger to use when bindings for this property are applied that have their UpdateSourceTrigger set to Default.

Exceptions

defaultValue is set to UnsetValue.

Examples

static FrameworkPropertyMetadata fpm;
fpm = new FrameworkPropertyMetadata(
    Double.NaN,
    (FrameworkPropertyMetadataOptions.AffectsRender |
      FrameworkPropertyMetadataOptions.BindsTwoWayByDefault),
    new PropertyChangedCallback(OnCurrentReadingChanged),
    new CoerceValueCallback(CoerceCurrentReading),
    true //Animation prohibited
    , UpdateSourceTrigger.PropertyChanged
);

Remarks

The type of the value provided for defaultValue must match or be related to the type specified in the original registration of the dependency property that this metadata will be applied to. Mismatches between metadata default value type and the type of the dependency property it is being applied to can be difficult to debug, because the mismatch is not detectable during compilation. The property system does not evaluate the effective value of a property until run time, so the result of a default value type/property type mismatch is a run-time error.

The value UnsetValue has special meaning in the property system, and cannot be used as a dependency property default value.

The isAnimationProhibited parameter sets the initial value of the IsAnimationProhibited property declared by the immediate base UIPropertyMetadata class.

For more information about the update source behavior for bindings, see Data Binding Overview.

Values marked as set flags in the flags parameter will set the Boolean value of FrameworkPropertyMetadata properties that match that FrameworkPropertyMetadataOptions flag's name to true. You can still change the values of the properties in the metadata, as long as the metadata has not yet been applied to a specific property system operation.

See also

Applies to