예제 #1
0
        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);
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
 public void SetBinding(DependencyProperty dp, string path)
 {
     this.SetBinding(dp, new Binding(path));
 }
예제 #4
0
        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;
        }
예제 #5
0
 internal DependencyPropertyKey(DependencyProperty dependencyProperty)
 {
     this.dependencyProperty = dependencyProperty;
 }
예제 #6
0
        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);
            }
        }
예제 #7
0
 internal bool IsUnset(DependencyProperty dependencyProperty)
 {
     return !this.properties.ContainsKey(dependencyProperty);
 }
예제 #8
0
        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;
        }
예제 #9
0
        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;
        }
예제 #10
0
 internal LocalValueEntry(DependencyProperty property, object value)
 {
     this.property = property;
     this.value    = value;
 }
예제 #11
0
 protected void OnFreezablePropertyChanged(
     DependencyObject oldValue,
     DependencyObject newValue,
     DependencyProperty property)
 {
     throw new NotImplementedException();
 }
예제 #12
0
 public Setter(DependencyProperty property, object value, string targetName)
 {
     this.Property = property;
     this.Value = value;
     this.TargetName = targetName;
 }
예제 #13
0
 public Setter(DependencyProperty property, object value)
 {
     this.Property = property;
     this.Value = value;
 }
예제 #14
0
 protected virtual void OnApply(DependencyProperty dp, Type targetType)
 {
 }
예제 #15
0
        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;
        }
예제 #16
0
        public void ClearValue(DependencyProperty dp)
        {
            if (this.IsSealed)
            {
                throw new InvalidOperationException("Cannot manipulate property values on a sealed DependencyObject");
            }

            this.properties.Remove(dp);
        }
예제 #17
0
        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);
        }
예제 #18
0
 public void CoerceValue(DependencyProperty dp)
 {
     PropertyMetadata pm = dp.GetMetadata(this);
     if (pm.CoerceValueCallback != null)
     {
         pm.CoerceValueCallback(this, this.GetValue(dp));
     }
 }
예제 #19
0
 internal bool IsRegistered(Type t, DependencyProperty dp)
 {
     return GetAllProperties(t).Contains(dp);
 }
예제 #20
0
        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;
        }
예제 #21
0
 protected virtual bool ShouldSerializeProperty(DependencyProperty dp)
 {
     throw new NotImplementedException();
 }
예제 #22
0
        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);
            }
        }
예제 #23
0
        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));
            }
        }
예제 #24
0
 public object ReadLocalValue(DependencyProperty dp)
 {
     object val = this.properties[dp];
     return val == null ? DependencyProperty.UnsetValue : val;
 }
예제 #25
0
 internal LocalValueEntry(DependencyProperty property, object value)
 {
     this.property = property;
     this.value = value;
 }
예제 #26
0
 internal void Merge(PropertyMetadata baseMetadata, DependencyProperty dp, Type targetType)
 {
     this.Merge(baseMetadata, dp);
     this.OnApply(dp, targetType);
     this.isSealed = true;
 }