Reputation: 279
I have a ListBox whose datacontext is an:
ObservableCollection<Item>
Item is a base class, and from it inherits a Potion class, and then from that inherits a HealthPotion class.
So:
Item -> Potion -> HealthPotion
My ListBox template looks something like this:
<DataTemplate>
<StackPanel Orientation="Vertical" Margin="0,0,0,17">
<TextBlock Text="{Binding PropertyFromItem}" />
<TextBlock Text="{Binding PropertyFromPotion}" />
<TextBlock Text="{Binding PropertyFromHealthPotion}" />
</StackPanel>
</DataTemplate>
For some reason, the textblock that binds to PropertyFromHealthPotion (grandchild of Item) won't display data, yet the other two will. Any ideas why?
Thanks in advance.
Upvotes: 0
Views: 159
Reputation: 7264
As discussed in comments:
Are you sure you have healthpotion in there? put a into the DataTemplate to check! Is the property public? if you're expecting it to change, do you RAISE PropertyChanged correctly? By all means, your code SHOULD work....
Upvotes: 2