My code behind file receives an instance object Session which has a property AvailableCountries that returns a List. Each Country object has a Name property which is a String.
I also want to display these Country objects using a data template which I simplified here.
My current code is after going through a WPF binding tutorial, only to discover that you couldn't bind to instance objects using XAML, so I modified it as follow based on another tutorial, but it still displays nothing.
I have another method that fills a second listbox manually which tells me that the country list is indeed passed correctly.
<UserControl.Resources>
<DataTemplate x:Key="countriesLayout" DataType="Country">
<StackPanel TextBlock.Foreground="Yellow">
<StackPanel HorizontalAlignment="Left">
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<ListBox Name="ctrlCountries"
ItemTemplate="{DynamicResource countriesLayout}"
IsSynchronizedWithCurrentItem="True"
/>
// In my code behind file I have:
private void onLoad(object sender, RoutedEventArgs e) {
ctrlCountries.DataContext = Session.AvailableCountries;
}