Ejemplo n.º 1
0
        public void AnimateBy(View instance, string behaviorKey)
        {
            AnimationBehavior behavior = Behaviors?.GetAnimationBehavior(behaviorKey);

            if (null != instance && null != behavior)
            {
                var          elementType  = instance.GetType();
                PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == behavior.Property);

                if (propertyInfo != null)
                {
                    object destinationValue = ConvertTo(behavior.DestValue, propertyInfo.PropertyType);

                    if (destinationValue != null)
                    {
                        if (0 <= behavior.StartTime)
                        {
                            AnimateBy(instance, behavior.Property, destinationValue, behavior.StartTime, behavior.EndTime);
                        }
                        else
                        {
                            AnimateBy(instance, behavior.Property, destinationValue);
                        }
                    }
                }
            }
            else
            {
                throw new XamlParseException(string.Format("Behaviors don't have key {0}", behaviorKey), new XmlLineInfo());
            }
        }