Exemplo n.º 1
0
        internal static DependencyProperty RegisterProperty(
            string name,
            Type propertyType,
            Type ownerType,
            object defaultValue,
            PropertyChangedCallback changed,
            ValidateValueCallback validate,
            bool isIndependentlyAnimated,
            CoerceValueCallback coerced)
        {
            // Override metadata for this particular object type. This defines
            // the methods that will be called when property actions (setting,
            // getting, invalidating) are taken for this specific object type.

            UIPropertyMetadata propertyMetadata;

            // If this property is animated using a property resource, we create
            // AnimatablePropertyMetadata instead of UIPropertyMetadata.

            if (isIndependentlyAnimated)
            {
                propertyMetadata = new IndependentlyAnimatedPropertyMetadata(defaultValue);
            }
            else
            {
                propertyMetadata = new UIPropertyMetadata(defaultValue);
            }

            propertyMetadata.PropertyChangedCallback = changed;

            if (coerced != null)
            {
                propertyMetadata.CoerceValueCallback = coerced;
            }

            // Register property with passed in default metadata.  The type of
            // defaultMetadata will determine whether this property is animatable.
            DependencyProperty dp = DependencyProperty.Register(
                name,
                propertyType,
                ownerType,
                propertyMetadata,
                validate);

            return(dp);
        }
Exemplo n.º 2
0
        internal static DependencyProperty RegisterProperty(
            string name,
            Type propertyType,
            Type ownerType,
            object defaultValue,
            PropertyChangedCallback changed,
            ValidateValueCallback validate,
            bool isIndependentlyAnimated,
            CoerceValueCallback coerced)
        {
            // Override metadata for this particular object type. This defines
            // the methods that will be called when property actions (setting,
            // getting, invalidating) are taken for this specific object type.

            UIPropertyMetadata propertyMetadata;

            // If this property is animated using a property resource, we create
            // AnimatablePropertyMetadata instead of UIPropertyMetadata.

            if (isIndependentlyAnimated)
            {
                propertyMetadata = new IndependentlyAnimatedPropertyMetadata(defaultValue);
            }
            else
            {
                propertyMetadata = new UIPropertyMetadata(defaultValue);
            }

            propertyMetadata.PropertyChangedCallback = changed;

            if (coerced != null)
            {
                propertyMetadata.CoerceValueCallback = coerced;
            }

            // Register property with passed in default metadata.  The type of
            // defaultMetadata will determine whether this property is animatable.
            DependencyProperty dp = DependencyProperty.Register(
                name,
                propertyType,
                ownerType,
                propertyMetadata,
                validate);

            return dp;
        }