Editare

Partajați prin


PropertyMetadata Constructors

Definition

Initializes a new instance of the PropertyMetadata class.

Overloads

PropertyMetadata()

Initializes a new instance of the PropertyMetadata class.

PropertyMetadata(Object)

Initializes a new instance of the PropertyMetadata class with a specified default value for the dependency property that this metadata will be applied to.

PropertyMetadata(PropertyChangedCallback)

Initializes a new instance of the PropertyMetadata class with the specified PropertyChangedCallback implementation reference.

PropertyMetadata(Object, PropertyChangedCallback)

Initializes a new instance of the PropertyMetadata class with the specified default value and PropertyChangedCallback implementation reference.

PropertyMetadata(Object, PropertyChangedCallback, CoerceValueCallback)

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

PropertyMetadata()

Initializes a new instance of the PropertyMetadata class.

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

Applies to

PropertyMetadata(Object)

Initializes a new instance of the PropertyMetadata class with a specified default value for the dependency property that this metadata will be applied to.

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

Parameters

defaultValue
Object

The default value to specify for a dependency property, usually provided as a value of some specific type.

Exceptions

defaultValue cannot be set to the value UnsetValue.

Examples

static PropertyMetadata pm;
pm = new PropertyMetadata(Double.NaN);

Remarks

The type of the value provided for defaultValue must be 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 mismatch will raise a run-time exception).

Although it is the default per the parameterless constructor, a defaultValue of UnsetValue cannot be specified. Attempting to do so will raise an exception.

Applies to

PropertyMetadata(PropertyChangedCallback)

Initializes a new instance of the PropertyMetadata class with the specified PropertyChangedCallback implementation reference.

public:
 PropertyMetadata(System::Windows::PropertyChangedCallback ^ propertyChangedCallback);
public PropertyMetadata (System.Windows.PropertyChangedCallback propertyChangedCallback);
new System.Windows.PropertyMetadata : System.Windows.PropertyChangedCallback -> System.Windows.PropertyMetadata
Public Sub New (propertyChangedCallback As PropertyChangedCallback)

Parameters

propertyChangedCallback
PropertyChangedCallback

Reference to a handler implementation that is to be called by the property system whenever the effective value of the property changes.

Examples

static PropertyMetadata pm;
pm = new PropertyMetadata(new PropertyChangedCallback(OnCurrentReadingChanged));

Applies to

PropertyMetadata(Object, PropertyChangedCallback)

Initializes a new instance of the PropertyMetadata class with the specified default value and PropertyChangedCallback implementation reference.

public:
 PropertyMetadata(System::Object ^ defaultValue, System::Windows::PropertyChangedCallback ^ propertyChangedCallback);
public PropertyMetadata (object defaultValue, System.Windows.PropertyChangedCallback propertyChangedCallback);
new System.Windows.PropertyMetadata : obj * System.Windows.PropertyChangedCallback -> System.Windows.PropertyMetadata
Public Sub New (defaultValue As Object, propertyChangedCallback As PropertyChangedCallback)

Parameters

defaultValue
Object

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

propertyChangedCallback
PropertyChangedCallback

Reference to a handler implementation that is to be called by the property system whenever the effective value of the property changes.

Exceptions

defaultValue cannot be set to the value UnsetValue.

Examples

static PropertyMetadata pm;
pm = new PropertyMetadata(
    Double.NaN,
    new PropertyChangedCallback(OnCurrentReadingChanged)
);

Remarks

The type of the value provided defaultValue must be 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 mismatch will raise a run-time exception).

Although it is the default per the parameterless constructor, a defaultValue of UnsetValue cannot be specified. Attempting to do so will raise an exception.

Applies to

PropertyMetadata(Object, PropertyChangedCallback, CoerceValueCallback)

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

public:
 PropertyMetadata(System::Object ^ defaultValue, System::Windows::PropertyChangedCallback ^ propertyChangedCallback, System::Windows::CoerceValueCallback ^ coerceValueCallback);
public PropertyMetadata (object defaultValue, System.Windows.PropertyChangedCallback propertyChangedCallback, System.Windows.CoerceValueCallback coerceValueCallback);
new System.Windows.PropertyMetadata : obj * System.Windows.PropertyChangedCallback * System.Windows.CoerceValueCallback -> System.Windows.PropertyMetadata
Public Sub New (defaultValue As Object, propertyChangedCallback As PropertyChangedCallback, coerceValueCallback As CoerceValueCallback)

Parameters

defaultValue
Object

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

propertyChangedCallback
PropertyChangedCallback

Reference to a handler implementation that is to be called by the property system whenever the effective value of the property changes.

coerceValueCallback
CoerceValueCallback

Reference to a handler implementation that is to be called whenever the property system calls CoerceValue(DependencyProperty) against this property.

Exceptions

defaultValue cannot be set to the value UnsetValue.

Examples

static PropertyMetadata pm;
pm = new PropertyMetadata(
    Double.NaN,
    new PropertyChangedCallback(OnCurrentReadingChanged),
    new CoerceValueCallback(CoerceCurrentReading)
);

Remarks

If you want to specify a CoerceValueCallback but not a PropertyChangedCallback, you can pass null for the propertyChangedCallback parameter.

The type of the value provided for defaultValue must be 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 mismatch will raise a run-time exception).

Although it is the default per the parameterless constructor, a defaultValue of UnsetValue cannot be specified. Attempting to do so will raise an exception.

Applies to