I have tried to bind the data into the ListView control:
<ListView Margin="8" Height="400" Width="650"
ItemsSource="{Binding Path=MyData}">
<ListView.View>
<GridView>
<GridViewColumn Header="ID" Width="Auto"
DisplayMemberBinding="Binding Path=ID}" >
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Path=Name}"
Header="Name" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Price}"
Header="Price" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Author}"
Header="Author" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Catalog}"
Header="Catalog" Width="100"/>
</GridView>
</ListView.View>
</ListView>
ObservableCollection<TableInfo> _MyData
public ObservableCollection<TableInfo> MyData{ get; set; }
However, it’s not display anything in the window but MyData is an ObservableCollection. How do I bind the data?
Tanya,
If you set your view model properly and if you’re sure that your MyData collection is not null or empty, try to remove the “Path” keywords from your xaml:
If this doesn’t help, check the debug output and post it, we will definitely figure something out.