Alex141 / CalcBinding

Advanced WPF Binding which supports expressions in Path property and other features
Apache License 2.0
638 stars 79 forks source link

CalcBinding can not be set with FrameworkElement.SetBinding #43

Closed bisato closed 7 years ago

bisato commented 8 years ago

The CalcBinding can not be set with: myLabel.SetBinding(Label.ContentProperty, calcBinding); because CalcBinding does not inherit BindingBase. How can this be achieved?

Alex141 commented 8 years ago

See how it achieved in integration tests on CalcBinding:

var targetObject = new TextBox();
var calcBinding = new CalcBinding.Binding(path);
targetObject.DataContext = source;

var bindingExpression = calcBinding.ProvideValue(new ServiceProviderMock(targetObject, targetProperty, resolvedTypes));

targetObject.SetValue(targetObject.TextProperty, bindingExpression);

You should use 'null' or empty class instead of ServiceProviderMock.

reference: https://github.com/Alex141/CalcBinding/blob/master/Tests/BaseSystemTests.cs line 174

bisato commented 7 years ago

very nice. Thanks.