Example #1
0
        public static void Bind(object source, string sourceProp, object target, string targetProp)
        {
            string            sourceEvent = sourceProp + "Changed";
            string            targetEvent = targetProp + "Changed";
            Type              sourceType  = source.GetType();
            Type              targetType  = target.GetType();
            EventInfo         ei1         = sourceType.GetEvent(sourceEvent);
            EventInfo         ei2         = targetType.GetEvent(targetEvent);
            BindingController bh          = new BindingController(source, sourceProp, target, targetProp);

            ei1.AddEventHandler(source, new EventHandler(bh.SourceChanged));
            ei2.AddEventHandler(target, new EventHandler(bh.TargetChanged));
            bh.TargetChanged(bh, EventArgs.Empty);
        }