示例#1
0
        /// <summary>
        /// Binds this binding (actually connects objects)
        /// </summary>
        /// <param name="source">The object that we will listen to for changes</param>
        /// <param name="target">The object we will be updating</param>
        /// <param name="srcProperty">The property on the source we will listen to</param>
        /// <param name="targetProperty">The property on target we will be updating</param>
        public void Bind(ViewModel source, TARGET target, string srcProperty, string targetProperty)
        {
            this.source         = source == null ? null : new MediaPoint.MVVM.Helpers.WeakReference <ViewModel>(source);
            this.target         = new MediaPoint.MVVM.Helpers.WeakReference <TARGET>(target);
            this.srcProperty    = srcProperty;
            this.targetProperty = targetProperty;

            Debug.Assert(this.srcProperty != null);
            Debug.Assert(this.targetProperty != null);
            Debug.Assert(this.target != null);

            // the ending eventwrapper to the target object and the right property
            if (source != null)
            {
                eventWrappers.Add(new EventWrapper <ViewModel, ViewModel>((ViewModel)source, this));
            }
        }
示例#2
0
 /// <summary>
 /// Constructor for a deep binding X.Y -> A.B.C...D which gives B.C...D as path
 /// </summary>
 /// <param name="root">Root object where the path starts from (A)</param>
 /// <param name="path">List of properties in path (B.C...D)</param>
 public Binder(ViewModel root, List <string> path)
     : this(path)
 {
     this.root = new MediaPoint.MVVM.Helpers.WeakReference <ViewModel>(root);
 }