public static DependencyProperty Register <T>( Expression <Func <TOwner, T> > propertyLamba, CastedPropertyChangedCallback propertyChangedCallback, CastedCoerceValueCallback <T>?coerceValueCallback = null, CastedValidateValueCallback <T>?validateValueCallback = null) { return(Register( propertyLamba, CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback), validateValueCallback)); }
public static DependencyPropertyKey RegisterReadOnly <T>( Expression <Func <TOwner, T> > propertyLamba, T defaultValue, CastedPropertyChangedCallback?propertyChangedCallback = null, CastedCoerceValueCallback <T>?coerceValueCallback = null, CastedValidateValueCallback <T>?validateValueCallback = null) { return(RegisterReadOnly( propertyLamba, CreatePropertyMetadata(defaultValue, propertyChangedCallback, coerceValueCallback), validateValueCallback)); }
public static DependencyProperty Register <T>( Expression <Func <TOwner, T> > propertyLamba, T defaultValue, FrameworkPropertyMetadataOptions flags, CastedPropertyChangedCallback?propertyChangedCallback = null, CastedCoerceValueCallback <T>?coerceValueCallback = null, bool isAnimationProhibited = false, UpdateSourceTrigger?defaultUpdateSourceTrigger = null, CastedValidateValueCallback <T>?validateValueCallback = null) { return(Register( propertyLamba, CreateFrameworkPropertyMetadata( defaultValue, flags, propertyChangedCallback, coerceValueCallback, isAnimationProhibited, defaultUpdateSourceTrigger), validateValueCallback)); }
/// <summary> /// Converts a <see cref="CastedValidateValueCallback{T}"/> to a <see cref="ValidateValueCallback"/>. /// </summary> /// <typeparam name="T">The value type.</typeparam> /// <param name="callback">The callback.</param> /// <returns>a <see cref="ValidateValueCallback"/> or <c>null</c> if the input is null.</returns> public static ValidateValueCallback DownCast <T>(CastedValidateValueCallback <T> callback) { return((callback == null) ? null : new ValidateValueCallback((value) => callback((T)value))); }
/// <summary> /// Registers a dependency with the dependency property system for the <see cref="TOwnerObject" /> based on the property passed in. /// </summary> /// <typeparam name="TProperty">The property type (inferred from the lambda).</typeparam> /// <param name="propertyLambda">The property indicator lambda.</param> /// <param name="defaultValue">The default value.</param> /// <param name="propChanged">The property changed handler.</param> /// <param name="coerceValue">The coerce value handler.</param> /// <param name="validateValue">The validate value handler.</param> /// <returns>The <see cref="DependencyProperty" /> that was created and registered with the system.</returns> public static DependencyProperty RegisterFP <TProperty>(Expression <Func <TOwnerObject, TProperty> > propertyLambda, TProperty defaultValue, CastedPropertyChangedCallback <TProperty> propChanged, CastedCoerceValueCallback <TProperty> coerceValue, CastedValidateValueCallback <TProperty> validateValue, FrameworkPropertyMetadataOptions options = FrameworkPropertyMetadataOptions.None) { var expression = propertyLambda?.Body as MemberExpression; ValidatePropertyExpression(expression); return(DependencyProperty.Register( expression.Member.Name, typeof(TProperty), typeof(TOwnerObject), new FrameworkPropertyMetadata(defaultValue, options, DownCast(propChanged), DownCast(coerceValue)), DownCast(validateValue) )); }
public static DependencyPropertyKey RegisterReadOnly <T>(Expression <Func <TOwner, T> > propertyLamba, PropertyMetadata typeMetadata, CastedValidateValueCallback <T>?validateValueCallback) { return(DependencyProperty.RegisterReadOnly(GetPropertyName(propertyLamba), typeof(T), OwnerType, typeMetadata, DownCast(validateValueCallback))); }
public static ValidateValueCallback?DownCast <T>(CastedValidateValueCallback <T>?callback) { return((callback != null) ? new ValidateValueCallback(value => callback((T)value)) : null); }