예제 #1
0
        public static TResult Get <T, TResult>(T target, Expression <Func <T, TResult> > reference)
            where T : class, INotifyPropertyChanged
        {
            var propertyName = Property.Path(reference);

            return(AttachedProperty.Get <TResult>(target, propertyName));
        }
예제 #2
0
        public static void Set <T, TValue>(T target, Expression <Func <T, TValue> > reference, TValue value)
            where T : class, INotifyPropertyChanged
        {
            var propertyName   = Property.Path(reference);
            var changedOverlap = new ChangedEventOverlap {
                Target = target
            };
            var changingOverlap = new ChangingEventOverlap {
                Target = target as INotifyPropertyChanging
            };

            if (changingOverlap.Source != null)
            {
                changingOverlap.Source.RaiseChanging(propertyName);
            }
            AttachedProperty.Set(target, propertyName, value);
            if (changedOverlap.Source != null)
            {
                changedOverlap.Source.RaiseChanged(propertyName);
            }
        }