예제 #1
0
 private AttachedProperty(string name, Type owningType, Type propertyType,
                          object defaultValue                     = null,
                          Func <object, bool> validate            = null,
                          AttachedPropertyChangedCallback changed = null)
 {
     Name         = name;
     OwningType   = owningType;
     PropertyType = propertyType;
     DefaultValue = defaultValue;
     Validate     = validate;
     Changed      = changed;
 }
예제 #2
0
        /// <remarks>
        ///     Parameters correspond to properties on this class.
        /// </remarks>
        public static AttachedProperty Create(
            string name, Type owningType, Type propertyType,
            object defaultValue                     = null,
            Func <object, bool> validate            = null,
            AttachedPropertyChangedCallback changed = null)
        {
            if (propertyType.IsValueType && defaultValue == null)
            {
                // Use activator to create uninitialized version of value type.
                defaultValue = Activator.CreateInstance(propertyType);
            }

            return(new AttachedProperty(name, owningType, propertyType, defaultValue, validate, changed));
        }