示例#1
0
 private void BindTarget(bool bind)
 {
     if (bind)
     {
         if (IsBinding)
         {
             if (propInfo != null && control != null)
             {
                 EventHandler handler = new EventHandler(this.Target_PropertyChanged);
                 propInfo.AddValueChanged(control, handler);
             }
             if (validateInfo != null)
             {
                 CancelEventHandler handler = new CancelEventHandler(this.Target_Validate);
                 validateInfo.AddEventHandler(control, handler);
             }
         }
     }
     else
     {
         if (propInfo != null && control != null)
         {
             EventHandler handler = new EventHandler(this.Target_PropertyChanged);
             propInfo.RemoveValueChanged(control, handler);
         }
         if (validateInfo != null)
         {
             CancelEventHandler handler = new CancelEventHandler(this.Target_Validate);
             validateInfo.RemoveEventHandler(control, handler);
         }
     }
 }
示例#2
0
        internal void SetBindingManagerBase(BindingManagerBase lManager)
        {
            if (bindingManager == lManager)
            {
                return;
            }

            // remove notification from the backEnd
            if (bindingManager != null && fieldInfo != null && bindingManager.IsBinding && !(bindingManager is CurrencyManager))
            {
                fieldInfo.RemoveValueChanged(bindingManager.Current, new EventHandler(PropValueChanged));
                fieldInfo = null;
            }

            this.bindingManager = lManager;
            CheckBinding();
        }
示例#3
0
        internal override void SetDataSource(Object dataSource)
        {
            if (this.dataSource != null && !String.IsNullOrEmpty(this.propName))
            {
                propInfo.RemoveValueChanged(this.dataSource, new EventHandler(PropertyChanged));
                propInfo = null;
            }

            this.dataSource = dataSource;

            if (this.dataSource != null && !String.IsNullOrEmpty(this.propName))
            {
                propInfo = TypeDescriptor.GetProperties(dataSource).Find(propName, true);
                if (propInfo == null)
                {
                    throw new ArgumentException(string.Format(SR.PropertyManagerPropDoesNotExist, propName, dataSource.ToString()));
                }
                propInfo.AddValueChanged(dataSource, new EventHandler(PropertyChanged));
            }
        }
示例#4
0
        private protected override void SetDataSource(object dataSource)
        {
            if (_dataSource != null && !string.IsNullOrEmpty(_propName))
            {
                _propInfo.RemoveValueChanged(_dataSource, new EventHandler(PropertyChanged));
                _propInfo = null;
            }

            _dataSource = dataSource;

            if (_dataSource != null && !string.IsNullOrEmpty(_propName))
            {
                _propInfo = TypeDescriptor.GetProperties(dataSource).Find(_propName, true);
                if (_propInfo is null)
                {
                    throw new ArgumentException(string.Format(SR.PropertyManagerPropDoesNotExist, _propName, dataSource.ToString()));
                }

                _propInfo.AddValueChanged(dataSource, new EventHandler(PropertyChanged));
            }
        }