I'm trying to set a binding passing properties as parameters but i can't find a way on how to do it. This works:
Binding bind = new Binding();
//Some code
var tb = Control as TextBlock;
tb.SetBinding(TextBlock.TextProperty, bind );
What i would like to works is similar to this:
public FrameworkElement Control {get;set;}
public string dp {get;set;}
public string TypeOfControl {get;set;}
var tb = Control as typeof(TypeOfControl);
tb.SetBinding(typeof(TypeOfControl).dp, bind );
I've already tried to follow this: DependencyProperty from string
var descriptor = DependencyPropertyDescriptor.FromName(dp,typeof(TextBlock), typeof(Control));
descriptor.SetValue(Control, bind);
But i get null value from descriptor.