i have two Database Tables: Account and AccountRecords. They are connected with a Foreign Key because every Account contains multiple Records. I use ObservableCollection to bind the ListBox with the Accounts:
<ListBox Name="ListAccount"
ItemsSource="{Binding CurrentHouse.Account}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="AccountNumber" />
<Binding Path="Name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Then I bind the DataGrid with the selected Item in the ListBox:
<DataGrid ItemsSource="{Binding ElementName=ListAccount, Path=SelectedItems}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{AccountNumber}"
Header="Nr"
FontSize="16" />
<DataGridTextColumn Binding="{Name}"
Header="Name"
FontSize="16" />
</DataGrid.Columns>
This is everything OK. My question is how can i show in my DataGrid the Records for each Account? The Records are in a separate Table. If i create a second Observable Collection how can show the Records and the Accounts in the DataGrid?
Thank you. Georg
You can use RowDetails Template. Example Code is Below:
XAML :
CodeBehind:
XAML