System.Windows.DependencyProperty.IsValidType C# (CSharp) Method

IsValidType() public method

public IsValidType ( object value ) : bool
value object
return bool
        public bool IsValidType(object value)
        {
            return PropertyType.IsInstanceOfType (value);
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Sets the value of a dependency property.
        /// </summary>
        /// <param name="property">The dependency property whose value is to be set.</param>
        /// <param name="value">The value to set.</param>
        /// <exception cref="System.ArgumentException">Value is of wrong type for this DependencyProperty.</exception>
        public void SetValue(DependencyProperty property, object value)
        {
            if (!property.IsValidType(value))
            {
                throw new ArgumentException("Value is of wrong type for this DependencyProperty.");
            }

            if (property.PropertyType.IsValueType)
            {
                SetValueType(property, value);
            }
            else
            {
                SetValueWeakRef(property, value);
            }
        }
All Usage Examples Of System.Windows.DependencyProperty::IsValidType