Example #1
0
        public static IBindable <TValue> Bind <TTarget, TValue>(this TTarget obj, Expression <Func <TTarget, TValue> > memberExpr,
                                                                NotificationMode mode = null)
        {
            var accessor = MemberAccessor.FromChainedMemberExpression(memberExpr.Body);

            accessor.RootObject = obj;
            return(new MemberBindable <TValue>(accessor, mode));
        }
Example #2
0
        public MemberBindable(MemberAccessor access, NotificationMode mode = null)
        {
            _accessor = access;
            var instance = _accessor.RootObject;
            var changed  = instance as INotifyPropertyChanged;

            if (changed != null)
            {
                changed.PropertyChanged += (sender, args) => {
                    if (args.PropertyName == access.MemberChain[0].Name)
                    {
                        NotifyChange();
                    }
                };
            }
            mode?.Subscribe(instance, this);
        }