Jaa


PropertyMetadata Constructors

Definition

Overloads

PropertyMetadata(Object)

Initializes a new instance of the PropertyMetadata class, using a property default value.

PropertyMetadata(Object, PropertyChangedCallback)

Initializes a new instance of the PropertyMetadata class, using a property default value and callback reference.

PropertyMetadata(Object)

Initializes a new instance of the PropertyMetadata class, using a property default value.

public:
 PropertyMetadata(Platform::Object ^ defaultValue);
 PropertyMetadata(IInspectable const& defaultValue);
public PropertyMetadata(object defaultValue);
function PropertyMetadata(defaultValue)
Public Sub New (defaultValue As Object)

Parameters

defaultValue
Object

Platform::Object

IInspectable

A default value for the property where this PropertyMetadata is applied.

Applies to

PropertyMetadata(Object, PropertyChangedCallback)

Initializes a new instance of the PropertyMetadata class, using a property default value and callback reference.

public:
 PropertyMetadata(Platform::Object ^ defaultValue, PropertyChangedCallback ^ propertyChangedCallback);
 PropertyMetadata(IInspectable const& defaultValue, PropertyChangedCallback const& propertyChangedCallback);
public PropertyMetadata(object defaultValue, PropertyChangedCallback propertyChangedCallback);
function PropertyMetadata(defaultValue, propertyChangedCallback)
Public Sub New (defaultValue As Object, propertyChangedCallback As PropertyChangedCallback)

Parameters

defaultValue
Object

Platform::Object

IInspectable

A default value for the property where this PropertyMetadata is applied.

propertyChangedCallback
PropertyChangedCallback

A reference to the callback to call for property changed behavior.

Examples

This example shows usage of this constructor. OnLabelChanged refers to a delegate implementation for a PropertyChangedCallback (not shown). To see more code that puts this example in context, see Custom dependency properties.

public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
  "Label",
  typeof(String),
  typeof(ImageWithLabelControl),
  new PropertyMetadata(null,new PropertyChangedCallback(OnLabelChanged))
);
Public Shared ReadOnly LabelProperty As DependencyProperty = _
    DependencyProperty.Register("Label", _
      GetType(String), GetType(ImageWithLabelControl), _
      New PropertyMetadata(Nothing, new PropertyChangedCallback(AddressOf OnLabelChanged)))
DependencyProperty^ ImageWithLabelControl::_LabelProperty = 
    DependencyProperty::Register("Label", 
    Platform::String::typeid,
    ImageWithLabelControl::typeid, 
    ref new PropertyMetadata(nullptr,
      ref new PropertyChangedCallback(&ImageWithLabelControl::OnLabelChanged))
    );

Remarks

If you want to establish a PropertyMetadata instance that has a property-changed callback method but not a default value, pass null for defaultValue.

If you pass a value for defaultValue, make sure that the type of that value is valid for the propertyType type from the dependency property's definition through the Register call. If you've created a type mismatch between registration parameter and metadata, the issue only manifests itself indirectly. You'll get runtime errors when you try to instantiate a type that has this dependency property value, you won't get any design-time or compile-time warning or error.

See also

Applies to