Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1088103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:01:37+00:00 2026-05-16T23:01:37+00:00

I want a simple sample program that nests collections within collections using Wpf DataGrid.

  • 0

I want a simple sample program that nests collections within collections using Wpf DataGrid.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:01:38+00:00Added an answer on May 16, 2026 at 11:01 pm

    Here’s an implementation using VB.Net codebehind. Code is needed only to create test data.

    Class MainWindow 
    
    Public Property cs As New List(Of c1)
    
    Sub New()
    
        ' This call is required by the designer.
        InitializeComponent()
    
        For i1 = 1 To 3
            Dim c1 = New c1
            cs.Add(c1)
            c1.c1text = i1
            For i2 = 1 To 3
                Dim c2 = New c2
                c1.c1col.Add(c2)
                c2.c2text = i1 & i2
                For i3 = 1 To 3
                    Dim c3 = New c3
                    c2.c2col.Add(c3)
                    c3.c3text = i1 & i2 & i3
                    For i4 = 1 To 3
                        Dim c4 = New c4
                        c3.c3col.Add(c4)
                        c4.c4text = i1 & i2 & i3 & i4
                        For i5 = 1 To 3
                            c4.c4col.Add(i1 & i2 & i3 & i4 & i5)
                        Next
                    Next
                Next
            Next
        Next
        DataGrid1.ItemsSource = cs
    End Sub
    
    End Class
    
    Public Class c1
        Public Property c1text As String
        Public Property c1col As New List(Of c2)
    End Class
    
    Public Class c2
        Public Property c2text As String
        Public Property c2col As New List(Of c3)
    End Class
    
    Public Class c3
        Public Property c3text As String
        Public Property c3col As New List(Of c4)
    End Class
    
    Public Class c4
        Public Property c4text As String
        Public Property c4col As New List(Of String)
    End Class
    

    Here’s the Xaml:

    <Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    
    <Grid>
        <DataGrid Name="DataGrid1" IsReadOnly="True" AutoGenerateColumns="False" >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding c1text}" />
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <DataGrid Name="DataGrid2" ItemsSource="{Binding c1col}" IsReadOnly="True" AutoGenerateColumns="False">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Binding="{Binding c2text}" />
                                    <DataGridTemplateColumn>
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <DataGrid Name="DataGrid3" ItemsSource="{Binding c2col}" IsReadOnly="True" AutoGenerateColumns="False">
                                                    <DataGrid.Columns>
                                                        <DataGridTextColumn Binding="{Binding c3text}" />
                                                        <DataGridTemplateColumn>
                                                            <DataGridTemplateColumn.CellTemplate>
                                                                <DataTemplate>
                                                                    <DataGrid Name="DataGrid4" ItemsSource="{Binding c3col}" IsReadOnly="True" AutoGenerateColumns="False">
                                                                        <DataGrid.Columns>
                                                                            <DataGridTextColumn Binding="{Binding c4text}" />
                                                                            <DataGridTemplateColumn>
                                                                                <DataGridTemplateColumn.CellTemplate>
                                                                                    <DataTemplate>
                                                                                        <DataGrid Name="DataGrid5" ItemsSource="{Binding c4col}" IsReadOnly="True" AutoGenerateColumns="False">
                                                                                            <DataGrid.Columns>
                                                                                                <DataGridTextColumn Binding="{Binding}" />
                                                                                            </DataGrid.Columns>
                                                                                        </DataGrid>
                                                                                    </DataTemplate>
                                                                                </DataGridTemplateColumn.CellTemplate>
                                                                            </DataGridTemplateColumn>
                                                                        </DataGrid.Columns>
                                                                    </DataGrid>
                                                                </DataTemplate>
                                                            </DataGridTemplateColumn.CellTemplate>
                                                        </DataGridTemplateColumn>
                                                    </DataGrid.Columns>
                                                </DataGrid>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
    

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want to make simple toggle program (that will be mapped to some
I want to create an extremely simple iPhone program that will open a telnet
I want to compile a simple hello-world-style program using the Windows command line. cl
I want to write a simple program that detect USB Wifi plugged computer and
I want to make a simple program that can restrict any communication over the
I want to make simple java program that will insert some text into current
Ok, so I want to run simple opengl program that I've written, on other
I'm having a bit of trouble. I want to create a simple program that
I want to create a simple program that will convert a pdf to a
I'm making a simple program that maintains a list of numbers, and I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.