Exemple #1
0
 public static PropertyMetadata CreatePropertyMetadata <T>(
     T defaultValue,
     CastedPropertyChangedCallback?propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback)
 {
     return(new PropertyMetadata(defaultValue, DownCast(propertyChangedCallback), DownCast(coerceValueCallback)));
 }
Exemple #2
0
 public static PropertyMetadata CreateUIPropertyMetadata <T>(
     T defaultValue,
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T> coerceValueCallback,
     bool isAnimationProhibited)
 {
     return(new UIPropertyMetadata(defaultValue, DownCast(propertyChangedCallback), DownCast(coerceValueCallback), isAnimationProhibited));
 }
Exemple #3
0
 public static PropertyMetadata CreatePropertyMetadata <T>(
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback)
 {
     return(new PropertyMetadata(DownCast(propertyChangedCallback))
     {
         CoerceValueCallback = DownCast(coerceValueCallback)
     });
 }
Exemple #4
0
 public static void OverrideMetadata <T>(
     DependencyProperty dp,
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback = null)
 {
     OverrideMetadata(
         dp,
         CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback));
 }
Exemple #5
0
 public static DependencyProperty AddOwner <T>(
     DependencyProperty dp,
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback = null)
 {
     return(AddOwner(
                dp,
                CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback)));
 }
Exemple #6
0
 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));
 }
Exemple #7
0
 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));
 }
Exemple #8
0
 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));
 }
Exemple #9
0
 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));
 }
Exemple #10
0
 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));
 }
Exemple #11
0
 /// <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)));
 }
Exemple #12
0
        /// <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)
                       ));
        }
Exemple #13
0
 /// <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))));
 }
Exemple #14
0
 public static CoerceValueCallback?DownCast <T>(CastedCoerceValueCallback <T>?callback)
 {
     return((callback != null) ? new CoerceValueCallback((d, baseValue) => callback((TOwner)d, (T)baseValue)) : null);
 }