Click here to Skip to main content
15,997,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,
I am working on nested Datagrid(Parent-child) grid in wpf. I am successful in binding the children to a row by using

<DataGrid.RowDetailsTemplate>

<DataGrid.RowDetailsTemplate>


But my problem is that I want to expand my child Grid also so that that every child row consists of another grid means the flow will be like this

Each Parent Row---> Contains Child Grid

EachChildRow------> Contains Sub child grid

Parent----Child-----Subchild

I am successful in working Parent--Child but my problem is that I am unable to attatctch a sub child grid to my child grid.... Comming excatly I am unable to attach a click event to that button... I attatch the click event to the expand button... The app is not running See the code for the expand button in Child grid


//Button Present in Parent Grid For Expanding Child... Working Correctly

<DataGrid>

XML
<DataGridTemplateColumn Header="C" >
                             <DataGridTemplateColumn.CellTemplate>
                                 <DataTemplate>
                                     <StackPanel Name="stk">
   <Button x:Name="btnCollapse" {Binding KitGroupingID}" Clickquot;btnCollapse_Click"    >
                                             <Image Source="../images/Plus.png" ></Image>
                                         </Button>
                                     </StackPanel>
                                 </DataTemplate>
                             </DataGridTemplateColumn.CellTemplate>
                         </DataGridTemplateColumn>

.
.
.
.//Exapnding Code
.
.
.

XML
<DataGrid.RowDetailsTemplate>
                           <DataTemplate>
                               <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"   >
                                   <DataGrid>
                                       <DataGrid.Columns>

                                           <DataGridTemplateColumn Header="D" >
                                               <DataGridTemplateColumn.CellTemplate>
                                                   <DataTemplate>
                                                   <StackPanel>
 <Button x:Name="btnCollapseChildren"<big>Click="btnCollpaseChild_Click"</big> >
                                                               <Image Source="../images/Plus.png" Cursor="Hand" Height="20" Width="15" Name="imgExpandChild" ></Image>
                                                           </Button>
                                                       </StackPanel>
                                                   </DataTemplate>
                                               </DataGridTemplateColumn.CellTemplate>
                                           </DataGridTemplateColumn>





You see the above code... If I add a click event to the child Grid I am getting Issue to Please solve my problem
Posted
Updated 11-Nov-13 18:30pm
v2

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