Hello,
I need to use reflection to get the binding value in a control that is a DataGridTemplateColumn (e.g HyperLinkButton). Does anyone know how I might do this? It seems simple enough to do this with a TextBlock because it has a “TextProperty” dependency property, but I can’t seem to get a binding expression from a control that does not have an immediate “TextProperty”. Here is the code I’m using to acquire the binding expression for a 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 that is a HyperLinkButton:
FieldInfo fi = fe.GetType().GetField("ContentProperty");
Does anyone know how I might be able to get the BindingExpression (and binding value) for the content of a HyperLinkButton?
Cheers,
sfx