private DependencyPropertyDescriptor(PropertyDescriptor property, Type componentType, DependencyProperty dependencyProperty) : base(dependencyProperty.Name, null) { _property = property; _componentType = componentType; _dependencyProperty = dependencyProperty; _metadata = dependencyProperty.GetMetadata(componentType); }
private DependencyProperty(bool isAttached, string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) { if (defaultMetadata == null) defaultMetadata = new PropertyMetadata(); if (defaultMetadata.DefaultValue == null) { var defaultValue = AutoDefaultValue(propertyType); if (validateValueCallback != null && !validateValueCallback(defaultValue)) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Failed to auto generate default value."), "defaultMetadata"); defaultMetadata.DefaultValue = defaultValue; } _globalIndex = System.Threading.Interlocked.Increment(ref _lastGlobalIndex); IsAttached = isAttached; DefaultMetadata = defaultMetadata; Name = name; OwnerType = ownerType; PropertyType = propertyType; ValidateValueCallback = validateValueCallback; }
internal void DoMerge(PropertyMetadata baseMetadata, DependencyProperty dp, Type targetType) { Merge(baseMetadata, dp); OnApply(dp, targetType); _isSealed = true; }
protected virtual void Merge(PropertyMetadata baseMetadata, DependencyProperty dp) { if (baseMetadata == null) throw new ArgumentNullException("baseMetadata"); if (dp == null) throw new ArgumentNullException("dp"); if (_defaultValue == null) _defaultValue = baseMetadata._defaultValue; if (_propertyChangedCallback == null) _propertyChangedCallback = baseMetadata._propertyChangedCallback; if (_coerceValueCallback == null) _coerceValueCallback = baseMetadata._coerceValueCallback; }
public DependencyProperty AddOwner(Type ownerType, PropertyMetadata typeMetadata) { DependencyObject.Register(ownerType, this); if (typeMetadata == null) typeMetadata = new PropertyMetadata(); OverrideMetadata(ownerType, typeMetadata); // MS seems to always return the same DependencyProperty return this; }
public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata) { return RegisterReadOnly(name, propertyType, ownerType, typeMetadata, null); }
public static DependencyPropertyKey RegisterReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback) { ValidateRegisterParameters(name, propertyType, ownerType); DependencyProperty dp = Register(name, propertyType, ownerType, typeMetadata, validateValueCallback); dp.ReadOnly = true; return new DependencyPropertyKey(dp); }
public static DependencyProperty RegisterAttached(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) { ValidateRegisterParameters(name, propertyType, ownerType); var dp = new DependencyProperty(true, name, propertyType, ownerType, defaultMetadata, validateValueCallback); DependencyObject.Register(ownerType, dp); return dp; }
public static DependencyPropertyKey RegisterAttachedReadOnly(string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata) { return RegisterAttachedReadOnly(name, propertyType, ownerType, defaultMetadata, null); }
public static DependencyProperty Register(string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback) { ValidateRegisterParameters(name, propertyType, ownerType); var dp = new DependencyProperty(false, name, propertyType, ownerType, typeMetadata, validateValueCallback); DependencyObject.Register(ownerType, dp); // is this needed? //dp.OverrideMetadata(ownerType, typeMetadata); return dp; }
public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata, DependencyPropertyKey key) { if (forType == null) throw new ArgumentNullException("forType"); if (typeMetadata == null) throw new ArgumentNullException("typeMetadata"); if (key == null) throw new ArgumentNullException("key"); // further checking? should we check // key.DependencyProperty == this? typeMetadata.DoMerge(DefaultMetadata, this, forType); _metadataByType.TryAdd(forType, typeMetadata); }
public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata) { if (forType == null) throw new ArgumentNullException("forType"); if (typeMetadata == null) throw new ArgumentNullException("typeMetadata"); if (ReadOnly) throw new InvalidOperationException( String.Format(CultureInfo.InvariantCulture, Resources.CannotOverrideMetadataOnReadonlyPropertyWithoutUsingDependencyPropertyKey, Name)); typeMetadata.DoMerge(DefaultMetadata, this, forType); _metadataByType.TryAdd(forType, typeMetadata); }
public void OverrideMetadata(Type forType, PropertyMetadata typeMetadata) { _dependencyProperty.OverrideMetadata(forType, typeMetadata, this); }