Esempio n. 1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            TransitionEffectBase transitionEffect = null;

            var stringValue = value as string;

            if (stringValue != null)
            {
                TransitionEffectKind effectKind;
                if (Enum.TryParse(stringValue, out effectKind))
                {
                    transitionEffect = new TransitionEffect(effectKind);
                }
            }
            else
            {
                transitionEffect = value as TransitionEffectBase;
            }

            if (transitionEffect == null)
            {
                throw new XamlParseException($"Could not parse to type {typeof (TransitionEffectKind).FullName} or {typeof (TransitionEffectBase).FullName}.");
            }

            return(transitionEffect);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            TransitionEffectBase?transitionEffect;

            if (value is string stringValue &&
                Enum.TryParse(stringValue, out TransitionEffectKind effectKind))
            {
                transitionEffect = new TransitionEffect(effectKind);
            }