示例#1
0
 public static PropertyMetadata CreateUIPropertyMetadata <T>(
     T defaultValue,
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T> coerceValueCallback,
     bool isAnimationProhibited)
 {
     return(new UIPropertyMetadata(defaultValue, DownCast(propertyChangedCallback), DownCast(coerceValueCallback), isAnimationProhibited));
 }
示例#2
0
 public static PropertyMetadata CreatePropertyMetadata <T>(
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback)
 {
     return(new PropertyMetadata(DownCast(propertyChangedCallback))
     {
         CoerceValueCallback = DownCast(coerceValueCallback)
     });
 }
示例#3
0
 public static void OverrideMetadata <T>(
     DependencyProperty dp,
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback = null)
 {
     OverrideMetadata(
         dp,
         CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback));
 }
示例#4
0
 public static DependencyProperty AddOwner <T>(
     DependencyProperty dp,
     CastedPropertyChangedCallback propertyChangedCallback,
     CastedCoerceValueCallback <T>?coerceValueCallback = null)
 {
     return(AddOwner(
                dp,
                CreatePropertyMetadata(propertyChangedCallback, coerceValueCallback)));
 }
示例#5
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));
 }
示例#6
0
文件: APUtils.cs 项目: ajbadaj/AJut
 /// <summary>
 /// Registers an attached property with the dependency property system.
 /// </summary>
 /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
 /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
 /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
 /// <param name="defaultValue">The default value for the attached property.</param>
 /// <param name="propChanged">The property changed callback delegate.</param>
 /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
 public DependencyProperty Register <TProperty>(StaticAPUtils.GetterFunc <TProperty> getter, StaticAPUtils.SetterFunc <TProperty> setter, TProperty defaultValue, CastedPropertyChangedCallback <TProperty> propChanged)
 {
     return(Register(getter, setter, new PropertyMetadata(defaultValue, DownCast(propChanged))));
 }
示例#7
0
文件: APUtils.cs 项目: ajbadaj/AJut
 /// <summary>
 /// Converts a <see cref="CastedPropertyChangedCallback"/> to a <see cref="PropertyChangedCallback"/>.
 /// </summary>
 /// <param name="callback">The callback.</param>
 /// <returns>a <see cref="PropertyChangedCallback"/> or <c>null</c> if the input is null.</returns>
 internal static PropertyChangedCallback DownCast <T> (CastedPropertyChangedCallback <T> callback)
 {
     return((callback == null) ? null : new PropertyChangedCallback((d, e) => callback(d, new DependencyPropertyChangedEventArgs <T>(e))));
 }
示例#8
0
文件: APUtils.cs 项目: ajbadaj/AJut
 /// <summary>
 /// Registers a readonly attached property with the dependency property system.
 /// Note the default value for this attached property will be default(<see cref="TProperty"/>)
 /// </summary>
 /// <typeparam name="TProperty">The type of the attached property (inferred)</typeparam>
 /// <param name="getter">The attached property's getter (verified for required verbiage and type).</param>
 /// <param name="setter">The attached property's setter (verified for required verbiage and type).</param>
 /// <param name="propChanged">The property changed callback delegate.</param>
 /// <returns>The <see cref="DependencyProperty"/> that was registered for this attached property.</returns>
 public DependencyPropertyKey RegisterReadOnly <TProperty>(StaticAPUtils.GetterFunc <TProperty> getter, StaticAPUtils.SetterFunc <TProperty> setter, CastedPropertyChangedCallback <TProperty> propChanged)
 {
     return(RegisterReadOnly(getter, setter, new FrameworkPropertyMetadata(default(TProperty), DownCast(propChanged))));
 }
示例#9
0
 /// <summary>
 /// Converts a <see cref="CastedPropertyChangedCallback"/> to a <see cref="PropertyChangedCallback"/>.
 /// </summary>
 /// <param name="callback">The callback.</param>
 /// <returns>a <see cref="PropertyChangedCallback"/> or <c>null</c> if the input is null.</returns>
 private static PropertyChangedCallback DownCast <T>(CastedPropertyChangedCallback <T> callback)
 {
     return((callback == null) ? null : new PropertyChangedCallback((d, e) => callback((TOwnerObject)d, new DependencyPropertyChangedEventArgs <T>(e))));
 }
示例#10
0
 /// <summary>
 /// Registers a readonly 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>
 /// <returns>The <see cref="DependencyProperty"/> that was created and registered with the system.</returns>
 public static DependencyPropertyKey RegisterReadOnly <TProperty>(Expression <Func <TOwnerObject, TProperty> > propertyLambda, TProperty defaultValue, CastedPropertyChangedCallback <TProperty> propChanged)
 {
     return(RegisterReadOnly(propertyLambda, new PropertyMetadata(defaultValue, DownCast(propChanged))));
 }
示例#11
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)
                       ));
        }
示例#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>
 /// <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))));
 }
示例#13
0
 /// <summary>
 /// Registers a dependency with the dependency property system for the <see cref="TOwnerObject"/> based on the property passed in.
 /// Note the default value for this dependency property will be default(<see cref="TProperty"/>)
 /// </summary>
 /// <typeparam name="TProperty">The property type (inferred from the lambda).</typeparam>
 /// <param name="propertyLambda">The property indicator lambda.</param>
 /// <param name="propChanged">The property changed handler.</param>
 /// <returns>The <see cref="DependencyProperty"/> that was created and registered with the system.</returns>
 public static DependencyProperty Register <TProperty>(Expression <Func <TOwnerObject, TProperty> > propertyLambda, CastedPropertyChangedCallback <TProperty> propChanged)
 {
     return(Register(propertyLambda, new PropertyMetadata(default(TProperty), DownCast(propChanged))));
 }