【发布时间】:2019-10-22 22:16:14
【问题描述】:
我正在尝试设置绑定传递属性作为参数,但我找不到如何做到这一点的方法。 这有效:
Binding bind = new Binding();
//Some code
var tb = Control as TextBlock;
tb.SetBinding(TextBlock.TextProperty, bind );
我想做的工作与此类似:
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 );
我已经尝试过这样做: DependencyProperty from string
var descriptor = DependencyPropertyDescriptor.FromName(dp,typeof(TextBlock), typeof(Control));
descriptor.SetValue(Control, bind);
但我从描述符中得到空值。
【问题讨论】:
标签: c# binding dependency-properties system.reflection