0

我有这段代码,它基本上将一个gridview 放置在gridview 的单元格下方 - 一种分层​​类型的显示。

但是,子网格视图看不到数据上下文。

我已经搜索并尝试了很多案例,但它不起作用。我的程序现在抱怨在绑定过程中发生死锁并崩溃......我不知道如何让我的子网格看到数据绑定......

<telerik:RadGridView Height="633" HorizontalAlignment="Left" Margin="301,0,0,0" Name="radGridView2" VerticalAlignment="Top" Width="1546" Grid.Row="1" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" ItemsSource="{Binding Collections}" BorderBrush="#FFD7D2D2" FontFamily="Mangal" FontSize="14" Loaded="radGridView2_Loaded" AutoGenerateColumns="False"
                         RowStyleSelector="{StaticResource rowStyleSelector}" GroupRenderMode="Flat" ShowColumnSortIndexes="True" CanUserFreezeColumns="False" CanUserResizeColumns="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewToggleRowDetailsColumn />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding SetToPending}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding CollectionId}" ToolTip="{Binding Notes}"  />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding CollectionDate, Converter={StaticResource dateConverter}}"/>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding IsAdvancedPayment}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding LocationId}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding LocationName}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding NumMachines}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding NumCollections}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Gross}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding OperatorCommission}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Actual}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding OverShort}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Advance}" ToolTip="{Binding AdvanceId}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding TotalActualIn}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding TotalActualOut}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Gross}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding LocationCommission}" />
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Notes}" />
        </telerik:RadGridView.Columns>
        <telerik:RadGridView.RowDetailsTemplate>
            <DataTemplate>
                <telerik:RadGridView ItemsSource="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type telerik:RadGridView}}}" Name="childGrid" ShowGroupPanel="False">
                </telerik:RadGridView>
            </DataTemplate>
        </telerik:RadGridView.RowDetailsTemplate>
    </telerik:RadGridView>
4

1 回答 1

0

我基本上找到了一个解决方案 - 子网格的 DataContext 是绑定到父网格的任何内容......所以绑定到父网格的集合是唯一子网格看到的集合......所以我只是添加了它收集我的数据上下文对象...但我很想知道如何使整个 DataContext 对 childgrid 可见

于 2013-12-05T15:46:29.663 回答