/// <summary> /// Applies the binding. /// </summary> /// <param name="target">The target.</param> /// <param name="property">The property.</param> internal void ApplyBinding(DependencyObject target, DependencyProperty property) { BindingBase binding = this.Binding; if (binding != null) { BindingBase clone = (BindingBase)XamlHelper.Clone(binding); clone.StringFormat = "{0:" + this.FormatString + "}"; BindingOperations.SetBinding(target, property, clone); } else { BindingOperations.ClearBinding(target, property); } }
/// <summary> /// Applies the binding. /// </summary> /// <param name="binding">The binding.</param> /// <param name="target">The target.</param> /// <param name="property">The property.</param> /// <param name="stringFormat">The string format.</param> internal void ApplyBinding(BindingBase binding, DependencyObject target, DependencyProperty property, string stringFormat) { if (binding != null) { if (stringFormat == null) { BindingOperations.SetBinding(target, property, binding); } else { BindingBase clone = (BindingBase)XamlHelper.Clone(binding); clone.StringFormat = stringFormat; BindingOperations.SetBinding(target, property, clone); } } else { BindingOperations.ClearBinding(target, property); } }