0

我有一个 Datagrid,在它的行详细信息模板中我有另一个 Datagrid

<DataGrid Name="dataGridWorkOrders" ItemsSource="{StaticResource workorders}" >
<DataGrid.RowDetailsTemplate>
  <DataTemplate>
        <Border BorderThickness="0" Background="BlanchedAlmond" Padding="10">
        <DataGrid IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Element=dataGridWorkOrders,path=selectedItem}">
  </DataGrid>
 </Border>

工单集合就像:

class WorkOrders : ObservableCollection<WorkOrder>
    {
        public WorkOrders()
        {
            var orderList = OrderDetailsProvider.GetOrders() as List<WorkOrder>;

            orderList.ForEach(
                        order => this.Add(order));
        }

WorkorderClass 具有以下作为比例公开的字段。

 private string orderID;
 private int totalQuantity;
 private string status;
 private ObservableCollection<Schedule> scheduleCollection;

现在在我的第二个数据网格中,我想绑定到当前选定数据网格的ScheduleCollection

4

1 回答 1

1

的数据上下文RowDetailsTemplate应该是选定的项目——所以你应该绑定到scheduleCollection

<DataGrid IsReadOnly="true" ItemsSource="{Binding scheduleCollection}">

(...并且要么使用AutoGenerateColumns="true",要么DataGridColumns手动添加)

于 2012-11-23T06:37:28.677 回答