Here is my XAML code:
<TextBlock x:Name="subTitle" Text="{Binding Name}" />
And my C# code:
PropertyInfo pi = ...;
subTitle.DataContext = pi;
The TextBlock displays simply nothing.
There is no DataContextChanged event but the TextBlock gets notified about the change because if I omit the path “Name” from the binding expression I get the ToString() representation of the DataContext. I can access no property of the bound object. There are no tools for debugging and I spent hours on this tiny but breaking issue.
Please help me solve this problem. Is it a bug or am I missing something? Thank you very much.
I’d guess that
PropertyInfo.Nameisn’t a dependency property and/or it doesn’t implementINotifyPropertyChanged.Create your own viewmodel object (which implements INotifyPropertyChanged) and use that for binding values to the view.