Using a Datagrid in a RowDetailsTemplate of another Datagrid

I would like to use a DataGrid in the RowDetailsTempalte of another Datagrid. This internal Datagrid must have its columns associated with the property of the current object in the external Datagrid. For example, if an external Datagrid displays all contacts by first and last name, if I select a row, I should see another Datagrid containing all the phone numbers associated with this contact. What interests me most is how internal Datagrid data is tied to external Datagrid data. Here are some XAMLs that I still started with:

<data:DataGrid MinHeight="700" x:Name="contacts">
                <data:DataGrid.Columns>                       
                    <data:DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"></data:DataGridTextColumn>
                    <data:DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"></data:DataGridTextColumn>                        
                 </data:DataGrid.Columns>
                <data:DataGrid.RowDetailsTemplate>
                    <DataTemplate>
                        <StackPanel Background="Black">
                            <StackPanel Background="White" Margin="16">
                                <data:DataGrid DataContext="Contact.Phones">

                                </data:DataGrid>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </data:DataGrid.RowDetailsTemplate>
            </data:DataGrid>
+3
source share
2 answers

: Datagrid Silverlight?.

DataGrid ItemsSource="{Binding Phones}" DataContext.

+1

RowDetailsTemplate: DataGrid.RowDetailsTemplate.

DetailsVisibilityChanged, DataContext , . RowDetailsTemplate.

-3

Source: https://habr.com/ru/post/1710375/


All Articles