public override TValue Coerce(object context, TValue value)
        {
            // Initialize property getters the first time.
            if (Factory == null)
            {
                // Get the dependency property factory.
                Type       controlType     = context.GetType();
                MemberInfo propertyFactory = controlType.GetMembers(typeof(DependencyPropertyFactory <TEnum>)).FirstOrDefault();

                if (propertyFactory == null)
                {
                    throw new InvalidImplementationException("No dependency property factory found in type: \"" + controlType + "\"");
                }

                Factory = (DependencyPropertyFactory <TEnum>)context.GetValue(propertyFactory);
            }

            // Pass the value of each dependent property.
            var dependentValues = EnumHelper <TEnum> .GetFlaggedValues(DependentProperties)
                                  .ToDictionary(p => p, p => Factory.GetValue(context as DependencyObject, p));

            return(Coerce(dependentValues, value));
        }
        public void OnGetValue(LocationInterceptionArgs args)
        {
            DependencyPropertyFactory <T> factory = WpfControlAspect <T> .PropertyFactories[_instance.GetType()];

            args.Value = factory.GetValue(args.Instance as DependencyObject, _property);
        }
示例#3
0
 public static ICommand GetLeftMouseUpCommand(FrameworkElement target)
 {
     return((ICommand)DependencyProperties.GetValue(target, Properties.LeftMouseUpCommand));
 }
 public static List <PropertyObserver> GetObservers(DependencyObject target)
 {
     return(DependencyProperties.GetValue(target, Properties.Observers) as List <PropertyObserver>);
 }