Click here to Skip to main content
15,918,303 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is the code:
XML
<sdk:DataGrid AutoGenerateColumns="False" Grid.Row="3" ItemsSource="{Binding ElementName=blockOrderDetailDomainDataSource, Path=Data}" Name="blockOrderDetailDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" RowDetailsVisibilityChanged="blockOrderDetailDataGrid_RowDetailsVisibilityChanged"  Margin="0,44,0,0" Grid.ColumnSpan="2" Grid.RowSpan="2">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn x:Name="blockOrderIdColumn1" Binding="{Binding Path=BlockOrderId, Mode=OneWay}" Header="Block Order Id" IsReadOnly="True" Width="SizeToHeader" />
                <sdk:DataGridTextColumn x:Name="executedQuantityColumn" Binding="{Binding Path=ExecutedQuantity}" Header="Executed Quantity" Width="SizeToHeader" />
                <sdk:DataGridCheckBoxColumn x:Name="isMarketPricedColumn1" Binding="{Binding Path=IsMarketPriced}" Header="Is Market Priced" Width="SizeToHeader" />

            </sdk:DataGrid.Columns>
            <sdk:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <sdk:DataGrid AutoGenerateColumns="True" Height="100" Name="orderDetailDataGrid"  RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="600">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn x:Name="blockOrderIdColumn" Binding="{Binding Path=BlockOrderId}" Header="Block Order Id" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="orderIdColumn" Binding="{Binding Path=OrderId, Mode=OneWay}" Header="Order Id" IsReadOnly="True" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="orderQualifierColumn" Binding="{Binding Path=OrderQualifier}" Header="Order Qualifier" Width="SizeToHeader" />

                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>

                </DataTemplate>
            </sdk:DataGrid.RowDetailsTemplate>
        </sdk:DataGrid>


Code behind for Item source of child datagrid(orderDetailDataGrid) is:
C#
private void blockOrderDetailDataGrid_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e)
        {
            try
            {
                if (e.Row.DataContext != null)
                {
                    var abc = from q in getOrder.OrderDetails
                              where q.BlockOrderId == ((BlockOrderDetail)e.Row.DataContext).BlockOrderId
                              select q;

                    ((DataGrid)e.DetailsElement).ItemsSource = abc;

                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, "Error", MessageBoxButton.OK);
            }
        }

Now how can i bound orderDetailDataGrid to data form.....
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900