很难将列表绑定到数据网格:
XAML:
<DataGrid Name="dgProductList"
ItemsSource="{Binding ProductList}">
<DataGridTextColumn Binding="{Binding ProductName}" Header="Item" />
<DataGridTextColumn Binding="{Binding Quantity}" Header="Qty" />
<DataGridTextColumn Binding="{Binding TotalPrice}" Header="Price" />
<DataGridTemplateColumn Width="*">
后面的代码:
public IList<SalesItem> ProductList = new List<SalesItem>();
public void LoadProduct(Product product)
{
SalesItem item = new SalesItem { ProductName = product.Name, Quantity = 1, TotalPrice = product.Price };
ProductList.Add(item);
}
它不加载。
谢谢你。