我有以下数据网格:
<DataGrid Name="dataGridWorkOrders" ItemsSource="{StaticResource workorders}" Grid.Row="1" IsReadOnly="True" HorizontalAlignment="Stretch" AutoGenerateColumns="False" VerticalAlignment="Top">
<DataGrid.Columns>
<DataGridTextColumn Header="Total Quantity" Binding="{Binding TotalQuantity}"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Border BorderThickness="0" Background="BlanchedAlmond" Padding="10">
<DataGrid IsReadOnly="True" ItemsSource="{Binding ScheduleCollection}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Total Quantity" Binding="{Binding Path=TotalQuantity, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
</DataGrid.Columns>
现在在 rowdetails 模板中,我尝试访问绑定到父数据网格行的 TotalQuantity。我尝试使用祖先但不工作
编辑
模型代码:
class WorkOrders : ObservableCollection<WorkOrder>
{
public WorkOrders()
{
var orderList = OrderDetailsProvider.GetOrders() as List<WorkOrder>;
orderList.ForEach(
order => this.Add(order));
}
}
public class WorkOrder:BaseEntity
{
private string orderID;
private int totalQuantity;
private string status;
private ObservableCollection<Schedule> scheduleCollection;
....All the fields exposed as proporties
}