/// <summary>
        /// Sets the specified <paramref name="binding"/> on the <paramref name="target"/> instance.
        /// </summary>
        internal void SetBinding(DependencyProperty dependencyProperty, Binding binding, ManagedWeakReference target)
        {
            if (GetPropertyDetails(dependencyProperty) is DependencyPropertyDetails details)
            {
                var bindingExpression =
                    new BindingExpression(
                        viewReference: target,
                        targetPropertyDetails: details,
                        binding: binding
                        );

                details.SetBinding(bindingExpression);

                if (Equals(binding.RelativeSource, RelativeSource.TemplatedParent))
                {
                    _templateBindings = _templateBindings.Add(bindingExpression);

                    ApplyBinding(bindingExpression, TemplatedParentPropertyDetails.GetValue());
                }
                else
                {
                    _bindings = _bindings.Add(bindingExpression);

                    if (bindingExpression.TargetPropertyDetails.Property.UniqueId == DataContextPropertyDetails.Property.UniqueId)
                    {
                        bindingExpression.DataContext = details.GetValue(DependencyPropertyValuePrecedences.Inheritance);
                    }
                    else
                    {
                        ApplyBinding(bindingExpression, DataContextPropertyDetails.GetValue());
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Resumes the <see cref="Binding"/> instances for reacting to DataContext changes
        /// </summary>
        internal void ResumeBindings()
        {
            if (_bindingsSuspended)
            {
                _bindingsSuspended = false;

                var bindings = _bindings.Data;

                for (int i = 0; i < bindings.Length; i++)
                {
                    bindings[i].ResumeBinding();
                }

                ApplyDataContext(DataContextPropertyDetails.GetValue());
            }
        }
Пример #3
0
 /// <summary>
 /// Gets the DataContext <see cref="Binding"/> instance, if any
 /// </summary>
 /// <returns></returns>
 internal BindingExpression FindDataContextBinding() => DataContextPropertyDetails.GetBinding();