Esempio n. 1
0
        /// <summary>
        /// Sets the binding between target and source.
        /// </summary>
        /// <returns>
        /// The binding expression.
        /// </returns>
        /// <param name='target'>
        /// The Target to bind to.
        /// </param>
        /// <param name='property'>
        /// The target Property to bind.
        /// </param>
        /// <param name='source'>
        /// The Source to bind to.
        /// </param>
        /// <param name='binding'>
        /// The source Binding.
        /// </param>
        public static BindingExpression SetBinding(this object target, string property, object source, Binding binding)
        {
            var expression = new BindingExpression(target, property, source, binding);
            
            var key = target;//GetDictionaryKey(target);
            if (!ExpressionDictionary.ContainsKey(key))
            {
                ExpressionDictionary.Add(key, new List<BindingExpression>() { expression });
            }
            else
            {
                ExpressionDictionary[key].Add(expression); 
            }

            return expression;
        }
Esempio n. 2
0
 /// <summary>
 /// Sets the binding between target and source.
 /// </summary>
 /// <returns>
 /// The binding expression.
 /// </returns>
 /// <param name='target'>
 /// The Target to bind to.
 /// </param>
 /// <param name='source'>
 /// The Source to bind to.
 /// </param>
 /// <param name='binding'>
 /// The source Binding.
 /// </param>
 public static BindingExpression SetBinding(this object target, object source, Binding binding)
 {
     return target.SetBinding(binding.PropertyName, source, binding);
 }
Esempio n. 3
0
        /// <summary>
        /// Initialize the binding instance.
        /// </summary>
        /// <param name='target'>
        /// The target object to bind to.
        /// </param>
        /// <param name='targetProperty'>
        /// The name of the Target property.
        /// </param>
        /// <param name='source'>
        /// The Source object to bind to.
        /// </param>
        /// <param name='binding'>
        /// The source Binding.
        /// </param>
        private void Initialize(object target, string targetProperty, object source, Binding binding)
        {
            this.target = new WeakReference(target);
            this.source = new WeakReference(source);
            this.TargetProperty = targetProperty;
            this.Binding = binding;

            this.RegisterForPropertyChangesOnSource();
            this.RegisterForPropertyChangesOnTarget();
            
            this.targetPropertyInfo = target.GetPropertyInfo(this.TargetProperty);
            
            this.UpdateTarget();
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MonoKit.DataBinding.BindingExpression"/> class.
 /// </summary>
 /// <param name='target'>
 /// The target object to bind to.
 /// </param>
 /// <param name='targetProperty'>
 /// The name of the target property.
 /// </param>
 /// <param name='source'>
 /// The source object to bind to.
 /// </param>
 /// <param name='binding'>
 /// The binding for the source object.
 /// </param>
 public BindingExpression(object target, string targetProperty, object source, Binding binding)
 {
     this.Initialize(target, targetProperty, source, binding);
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MonoKit.DataBinding.BindingDefinition"/> class.
 /// </summary>
 /// <param name='targetProperty'>
 /// The name of the target property to bind to.
 /// </param>
 /// <param name='binding'>
 /// The source binding.
 /// </param>
 public BindingDefinition(string targetProperty, Binding binding)
 {
     this.PropertyName = targetProperty;
     this.Binding = binding;
 }