public static PropertyMetadata CreatePropertyMetadata <T>( T defaultValue, CastedPropertyChangedCallback?propertyChangedCallback, CastedCoerceValueCallback <T>?coerceValueCallback) { return(new PropertyMetadata(defaultValue, DownCast(propertyChangedCallback), DownCast(coerceValueCallback))); }
public static PropertyMetadata CreateUIPropertyMetadata <T>( T defaultValue, CastedPropertyChangedCallback propertyChangedCallback, CastedCoerceValueCallback <T> coerceValueCallback, bool isAnimationProhibited) { return(new UIPropertyMetadata(defaultValue, DownCast(propertyChangedCallback), DownCast(coerceValueCallback), isAnimationProhibited)); }
public static PropertyMetadata CreatePropertyMetadata <T>( CastedPropertyChangedCallback propertyChangedCallback, CastedCoerceValueCallback <T>?coerceValueCallback) { return(new PropertyMetadata(DownCast(propertyChangedCallback)) { CoerceValueCallback = DownCast(coerceValueCallback) }); }
public static void OverrideMetadata <T>( DependencyProperty dp, CastedPropertyChangedCallback propertyChangedCallback, CastedCoerceValueCallback <T>?coerceValueCallback = null) { OverrideMetadata( dp, CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback)); }
public static DependencyProperty AddOwner <T>( DependencyProperty dp, CastedPropertyChangedCallback propertyChangedCallback, CastedCoerceValueCallback <T>?coerceValueCallback = null) { return(AddOwner( dp, CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback))); }
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 PropertyMetadata CreateFrameworkPropertyMetadata <T>( T defaultValue, FrameworkPropertyMetadataOptions flags, CastedPropertyChangedCallback?propertyChangedCallback = null, CastedCoerceValueCallback <T>?coerceValueCallback = null, bool isAnimationProhibited = false, UpdateSourceTrigger?defaultUpdateSourceTrigger = null) { return(defaultUpdateSourceTrigger.HasValue ? new FrameworkPropertyMetadata(defaultValue, flags, DownCast(propertyChangedCallback), DownCast(coerceValueCallback), isAnimationProhibited, defaultUpdateSourceTrigger.Value) : new FrameworkPropertyMetadata(defaultValue, flags, DownCast(propertyChangedCallback), DownCast(coerceValueCallback), isAnimationProhibited)); }
public static void OverrideMetadata <T>( DependencyProperty dp, T defaultValue, FrameworkPropertyMetadataOptions flags, CastedPropertyChangedCallback?propertyChangedCallback = null, CastedCoerceValueCallback <T>?coerceValueCallback = null, bool isAnimationProhibited = false, UpdateSourceTrigger?defaultUpdateSourceTrigger = null) { OverrideMetadata( dp, CreateFrameworkPropertyMetadata( defaultValue, flags, propertyChangedCallback, coerceValueCallback, isAnimationProhibited, defaultUpdateSourceTrigger)); }
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="CastedCoerceValueCallback{T}"/> to a <see cref="CoerceValueCallback"/>. /// </summary> /// <typeparam name="T">The value type</typeparam> /// <param name="callback">The callback.</param> /// <returns>a <see cref="CoerceValueCallback"/> or <c>null</c> if the input is null.</returns> public static CoerceValueCallback DownCast <T>(CastedCoerceValueCallback <T> callback) { return((callback == null) ? null : new CoerceValueCallback((d, baseValue) => callback((TOwnerObject)d, baseValue))); }
/// <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) )); }
/// <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> /// <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, FrameworkPropertyMetadataOptions options = FrameworkPropertyMetadataOptions.None) { return(Register(propertyLambda, new FrameworkPropertyMetadata(defaultValue, options, DownCast(propChanged), DownCast(coerceValue)))); }
public static CoerceValueCallback?DownCast <T>(CastedCoerceValueCallback <T>?callback) { return((callback != null) ? new CoerceValueCallback((d, baseValue) => callback((TOwner)d, (T)baseValue)) : null); }