我正在尝试使用一个 DataGrid 和类在 Silverlight 中创建简单的数据驱动应用程序。我无法将数据显示到 Datagrid 中。
这是我的代码,
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding Name}" Header="Item Name"/>
<sdk:DataGridTextColumn Binding="{Binding Barode}" Header="Barcode"/>
<sdk:DataGridTextColumn Binding="{Binding Price}" Header="Price"/>
<sdk:DataGridTextColumn Binding="{Binding Cost}" Header="Cost"/>
<sdk:DataGridTextColumn Binding="{Binding Stock}" Header="Stock"/>
<sdk:DataGridTextColumn Binding="{Binding Department}" Header="Department"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
这是我的课,
public ItemDetails()
{
_itemDetails = new ObservableCollection<ItemInf>
{
new ItemInf {Barcode = "123456",Name = "12Pk Corona Extra",Price = 16.00, Cost = 15.99, Stock = 23, Department = "Beer"},
new ItemInf {Barcode = "234567",Name = "6Pk Corona Extra",Price = 7.99, Cost = 5.99, Stock = 29, Department = "Beer"},
};
}
任何人都可以帮助我在哪里犯错或我做错了什么。