This works
<Border>
<StackPanel>
<TextBlock Text="{Binding Foo.Info1}" />
<TextBlock Text="{Binding Foo.Info2}" />
</StackPanel>
</Border>
but this doesn’t
<Border DataContext="Foo">
<StackPanel>
<TextBlock Text="{Binding Info1}" />
<TextBlock Text="{Binding Info2}" />
</StackPanel>
</Border>
My understanding is the if you set datacontext for a parent, the children would be able to bind to the properties. Is Border not a good element to be a parent?
I’m very new to data binding in XAML. Can someone tell me why the second snipped doesn’t work and point me in the right direction?
Use
Without binding the datacontext of your border is just “Foo” string, which doesn’t have any Info1, Info2 properties
Hope this helps