Try using ItemsSource="{Binding}" instead.
Hi Rob,
I think part of the problem is you are still thinking WinForms. Instead of binding a Grid to a Table, how about binding the ListBox to a Collection?
Try this instead:
1) Create another class that implements INotifyPropertyChanged. We are going to use this class for the DataContext. Think of it as your BindingEngine. I typically make this the DataContext of the Window itself, making it available anywhere in the Window.
2) Expose a property in the new class that is an ObservableCollection, where YourType is another class that implements INotifyPropertyChanged and exposes the data properties you wish to display.
3) Create a method in the Engine that populates your Collection. Then fire the PropertyChanged event when it is populated.
4) Bind the ListBox ItemsSource to the Property.
5) Create an ItemTemplate and use the property names from YourType for the Binding.
This is psuedo-code, but should get you close:
<Window>
<Window.Resources>
<ObjectDataProvider x:Key="MyEngineDS" ObjectType="{x:Type MyEngine:MyEngineNamespace}" d:IsDataSource="True"/>
<DataTemplate x:Key="ItemTemplate1">
<TextBlock Text="{Binding MyPropertyName}" />
</DataTemplate>
</Window.Resources>
<Window.DataContext>
<Binding Mode="OneWay" Source="{StaticResource MyEngineDS}"/>
</Window.DataContext>
<Grid x:Name="LayoutRoot">
<ListBox ItemsSource="MyCollection" ItemTemplate="{DynamicResource ItemTemplate1}" />
</Grid>
</Window>
Hope this helps.
I made a sample app and discovered you need to surround your GridView with ListView.View and set your ItemsSource to {Binding} just like the following:
<ListView Name="Preview" ItemsSource="{Binding}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=FormalName}" />
</GridView>
</ListView.View>
</ListView>