Esempio n. 1
0
        private Binding CreateBinding(object target, DependencyPropertyDescriptor property, Setter setter)
        {
            if (setter.Value is BindingBase &&
                target is DependencyObject)
            {
                this.attachedPropertySlot = AttachedPropertyManager.GetAndBindAttachedPropertySlot((DependencyObject)target, (BindingBase)setter.Value);

                var binding = new Binding
                {
                    Path   = new PropertyPath("(0)", this.attachedPropertySlot.DependencyProperty),
                    Source = target,
                    Mode   = BindingMode.OneWay
                };

                return(binding);
            }
            else
            {
                var binding = new Binding("Value")
                {
                    Source = setter,
                    Mode   = property.IsReadOnly
                                             ? BindingMode.OneWay
                                             : BindingMode.TwoWay,
                    Converter = new DynamicResourceToValueConverter(target)
                };


                return(binding);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ConditionItem" /> class.
        /// </summary>
        public ConditionItem(BindingBase conditionBinding, DependencyObject conditionContainer, object targetValue)
            : this(conditionContainer, targetValue, BindingDisplayHelper.BuildBindingDescriptiveString(conditionBinding))
        {
            this.conditionBinding = conditionBinding;

            this.attachedPropertySlot = AttachedPropertyManager.GetAndBindAttachedPropertySlot(this.conditionContainer, this.conditionBinding);

            this.BindCurrentValue(conditionContainer, this.attachedPropertySlot.DependencyProperty);
        }