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); if (this.attachedPropertySlot is null) { return(null); } var binding = new Binding { Path = new PropertyPath("(0)", this.attachedPropertySlot.DependencyProperty), Source = target, Mode = BindingMode.OneWay }; return(binding); } else { var binding = new Binding(nameof(System.Windows.Setter.Value)) { Source = setter, Mode = property.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay, Converter = new DynamicResourceToValueConverter(target) }; return(binding); } }
/// <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); }