public void SetBinding(DependencyProperty dp, BindingBase binding) { Binding b = binding as Binding; if (b == null) { throw new NotSupportedException("Unsupported binding type."); } this.SetBinding(dp, b); }
protected virtual void Merge(PropertyMetadata baseMetadata, DependencyProperty dp) { if (this.defaultValue == null) { this.defaultValue = baseMetadata.defaultValue; } if (this.propertyChangedCallback == null) { this.propertyChangedCallback = baseMetadata.propertyChangedCallback; } if (this.coerceValueCallback == null) { this.coerceValueCallback = baseMetadata.coerceValueCallback; } }
public void SetBinding(DependencyProperty dp, string path) { this.SetBinding(dp, new Binding(path)); }
private object GetDefaultValue(DependencyProperty dp) { PropertyMetadata metadata = dp.GetMetadata(this); FrameworkPropertyMetadata frameworkMetadata = metadata as FrameworkPropertyMetadata; object result = metadata.DefaultValue; if (frameworkMetadata != null && frameworkMetadata.Inherits) { if (this.dependencyParent != null) { result = this.dependencyParent.GetValue(dp); } } return result; }
internal DependencyPropertyKey(DependencyProperty dependencyProperty) { this.dependencyProperty = dependencyProperty; }
internal static void Register(Type t, DependencyProperty dp) { Dictionary<string, DependencyProperty> typeDeclarations; if (!propertyDeclarations.TryGetValue(t, out typeDeclarations)) { typeDeclarations = new Dictionary<string, DependencyProperty>(); propertyDeclarations.Add(t, typeDeclarations); } if (!typeDeclarations.ContainsKey(dp.Name)) { typeDeclarations[dp.Name] = dp; } else { throw new ArgumentException("A property named " + dp.Name + " already exists on " + t.Name); } }
internal bool IsUnset(DependencyProperty dependencyProperty) { return !this.properties.ContainsKey(dependencyProperty); }
public static DependencyProperty RegisterAttached( string name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) { if (defaultMetadata == null) { defaultMetadata = new PropertyMetadata(); } DependencyProperty dp = new DependencyProperty( true, name, propertyType, ownerType, defaultMetadata, validateValueCallback); DependencyObject.Register(ownerType, dp); return dp; }
public static DependencyProperty Register( string name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback) { PropertyMetadata defaultMetadata; if (typeMetadata == null) { defaultMetadata = typeMetadata = new PropertyMetadata(); } else { defaultMetadata = new PropertyMetadata(typeMetadata.DefaultValue); } DependencyProperty dp = new DependencyProperty( false, name, propertyType, ownerType, defaultMetadata, validateValueCallback); DependencyObject.Register(ownerType, dp); dp.OverrideMetadata(ownerType, typeMetadata); return dp; }
internal LocalValueEntry(DependencyProperty property, object value) { this.property = property; this.value = value; }
protected void OnFreezablePropertyChanged( DependencyObject oldValue, DependencyObject newValue, DependencyProperty property) { throw new NotImplementedException(); }
public Setter(DependencyProperty property, object value, string targetName) { this.Property = property; this.Value = value; this.TargetName = targetName; }
public Setter(DependencyProperty property, object value) { this.Property = property; this.Value = value; }
protected virtual void OnApply(DependencyProperty dp, Type targetType) { }
public BindingExpression SetBinding(DependencyProperty dp, Binding binding) { PropertyPathParser pathParser = new PropertyPathParser(); BindingExpression expression = new BindingExpression(pathParser, this, dp, binding); object oldValue = this.GetValue(dp); object newValue = expression.GetValue(); this.propertyBindings.Add(dp, expression); this.SetValueInternal(dp, oldValue, newValue); return expression; }
public void ClearValue(DependencyProperty dp) { if (this.IsSealed) { throw new InvalidOperationException("Cannot manipulate property values on a sealed DependencyObject"); } this.properties.Remove(dp); }
public void SetValue(DependencyProperty dp, object value) { if (this.IsSealed) { throw new InvalidOperationException("Cannot manipulate property values on a sealed DependencyObject."); } if (value != DependencyProperty.UnsetValue && !dp.IsValidType(value)) { throw new ArgumentException("Value is not of the correct type for this DependencyProperty."); } if (dp.ValidateValueCallback != null && !dp.ValidateValueCallback(value)) { throw new Exception("Value does not validate."); } object oldValue = this.GetValue(dp); this.propertyBindings.Remove(dp); this.SetValueInternal(dp, oldValue, value); }
public void CoerceValue(DependencyProperty dp) { PropertyMetadata pm = dp.GetMetadata(this); if (pm.CoerceValueCallback != null) { pm.CoerceValueCallback(this, this.GetValue(dp)); } }
internal bool IsRegistered(Type t, DependencyProperty dp) { return GetAllProperties(t).Contains(dp); }
public object GetValue(DependencyProperty dp) { object val; if (!this.properties.TryGetValue(dp, out val)) { val = this.GetDefaultValue(dp); if (val == null && dp.PropertyType.IsValueType) { val = Activator.CreateInstance(dp.PropertyType); } } return val; }
protected virtual bool ShouldSerializeProperty(DependencyProperty dp) { throw new NotImplementedException(); }
public void InvalidateProperty(DependencyProperty dp) { BindingExpressionBase binding; if (this.propertyBindings.TryGetValue(dp, out binding)) { object oldValue = this.GetValue(dp); object newValue = binding.GetValue(); this.SetValueInternal(dp, oldValue, newValue); } }
private void SetValueInternal(DependencyProperty dp, object oldValue, object newValue) { PropertyMetadata metadata = dp.GetMetadata(this); if (metadata.CoerceValueCallback != null) { newValue = metadata.CoerceValueCallback(this, newValue); } if (newValue != DependencyProperty.UnsetValue && dp.IsValidValue(newValue)) { this.properties[dp] = newValue; } else { this.properties.Remove(dp); newValue = this.GetValue(dp); } if (!this.AreEqual(oldValue, newValue)) { this.OnPropertyChanged(new DependencyPropertyChangedEventArgs(dp, oldValue, newValue)); } }
public object ReadLocalValue(DependencyProperty dp) { object val = this.properties[dp]; return val == null ? DependencyProperty.UnsetValue : val; }
internal void Merge(PropertyMetadata baseMetadata, DependencyProperty dp, Type targetType) { this.Merge(baseMetadata, dp); this.OnApply(dp, targetType); this.isSealed = true; }