PropertyMetadata PropertyMetadata PropertyMetadata PropertyMetadata Constructors

Definition

Overloads

PropertyMetadata(Object) PropertyMetadata(Object) PropertyMetadata(Object) PropertyMetadata(Object)

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

PropertyMetadata(Object, PropertyChangedCallback) PropertyMetadata(Object, PropertyChangedCallback) PropertyMetadata(Object, PropertyChangedCallback) PropertyMetadata(Object, PropertyChangedCallback)

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

PropertyMetadata(Object) PropertyMetadata(Object) PropertyMetadata(Object) PropertyMetadata(Object)

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

public : PropertyMetadata(Platform::Object defaultValue)
PropertyMetadata(winrt::Windows::Foundation::IInspectable defaultValue) const;
public PropertyMetadata(Object defaultValue)
Public Sub New(defaultValue As Object)

Parameters

defaultValue
Object Object

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

PropertyMetadata(Object, PropertyChangedCallback) PropertyMetadata(Object, PropertyChangedCallback) PropertyMetadata(Object, PropertyChangedCallback) 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(winrt::Windows::Foundation::IInspectable defaultValue, PropertyChangedCallback propertyChangedCallback) const;
public PropertyMetadata(Object defaultValue, PropertyChangedCallback propertyChangedCallback)
Public Sub New(defaultValue As Object, propertyChangedCallback As PropertyChangedCallback)

Parameters

defaultValue
Object Object

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

propertyChangedCallback
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