コード例 #1
0
        // Exceptions:
        //   System.ArgumentNullException:
        //     source object is null.
        //
        //   System.ArgumentException:
        //     source object is not null and is not a valid type that can be converted to
        //     a System.Windows.GridLength.
        /// <summary>
        /// Attempts to convert a specified object to an instance of System.Windows.GridLength.
        /// </summary>
        /// <param name="context">Describes the context information of a type.</param>
        /// <param name="culture">Cultural specific information that should be respected during conversion.</param>
        /// <param name="value">The object being converted.</param>
        /// <returns>
        /// The instance of System.Windows.GridLength that is created from the converted
        /// source.
        /// </returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw GetConvertFromException(value);
            }

            if (value is string)
            {
                return(GridLength.INTERNAL_ConvertFromString((string)value));
            }

            return(base.ConvertFrom(context, culture, value));
        }