【发布时间】:2012-03-05 09:09:18
【问题描述】:
我有以下数据类:
class CustomerProducts
{
public string Id { get; set; }
public List<ProductId> Products { get; set; }
}
还有以下 XAML:
<DataGrid Name="grd_CustomerProducts" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:MainWindow, AncestorLevel=1}, Path=CustomerOverview}" />
注意:CustomerOverview 是主窗口中的 ObservableCollection<CustomerProducts>
我希望将CustomerOverview 集合绑定到DataGrid,以便您获得客户ID 和产品中所有ID 的计数。例如:
身份证........|产品数量
0001a | 3
bb032 | 0
3rt640 | 99
如何更改我的 XAML 来实现这一点,还是需要实现其他东西?
【问题讨论】:
标签: c# wpf data-binding observablecollection