I need to use reflection to get the binding value in a control DataGridTemplateColumn(e.g. HyperLinkButton). Does anyone know how I can do this?
It seems simple enough to do this with TextBlock, because it has a dependency property TextProperty, but I cannot get the binding expression from a control that does not have a direct one TextProperty. Here's the Im code used to get the binding expression for TextBlock:
FrameworkElement fe = (FrameworkElement)dependencyObj;
FieldInfo fi = fe.GetType().GetField("TextProperty");
BindingExpression bindingExpression = fe.GetBindingExpression((DependencyProperty)fi.GetValue(null))
However, the following code never works for a dependency object, which is HyperLinkButton:
FieldInfo fi = fe.GetType().GetField("ContentProperty");
Does anyone know how I can get BindingExpression(and the binding value) for the content HyperLinkButton?
source
share