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

  • Home
  • SEARCH
  • 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 7737655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:03:32+00:00 2026-06-01T08:03:32+00:00

I am attempting to create a ListView control which is populated via a binding

  • 0

I am attempting to create a ListView control which is populated via a binding to an ObservableCollection, which itself contains another ObservableCollection from which I need to display data in the ListView.

To clarify I have an object hierarchy as follows:

ClassA
{
    int ID = 123;
    string Name = "Value";
}

ClassB
{
    int ID = 456;
    ObservableCollection<ClassA> CollectionOfClassA;
}

ClassC
{
    int ID = 789;
    ObservableCollection<ClassB> CollectionOfClassB;
}

From this I would like to end up with the following ListView layout:

(ClassC.CollectionOfClassB ListView)
+-------------+-------------+------------------+--------------------------------+
|  ClassB.ID  |  CollectionOfClassA.ClassA.ID  |  CollectionOfClassA.ClassA.ID  |
+-------------+-------------+------------------+--------------------------------+
|  ClassB.ID  |  CollectionOfClassA.ClassA.ID  |  CollectionOfClassA.ClassA.ID  |
+-------------+-------------+------------------+--------------------------------+

To achieve this I would assume I need to bind my ListView to my CollectionOfClassB collection, however, the datatemplate structure and subsequent binding for producing the rows has me a bit stumped.

Can anyone assist me with this please?

Many thanks,

Edit:

The first column in the table above references the ID field for the indexed object in the ClassC.CollectionOfClassB collection, each row being an individual object stored in the CollectionOfClassB.

Each of the ClassB objects stored in CollectionOfClassB has its own CollectionOfClassA, which I am attempting to place in the listview on the same row as its parent. Each ClassA object in CollectionOfClassA being a column.

Edit 2:

The first column is populated by the ID field from ClassB for the current item in the CollectionOfClassB, the subsequent columns are populated with data from each item in the CollectionOfClassA. The column header would be ClassA.ID, whilst the content would be ClassA.Name for example.

I am looking for example XAML markup that will allow me to achieve this.

  • 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-06-01T08:03:33+00:00Added an answer on June 1, 2026 at 8:03 am

    If you know that ClassB.CollectionOfClassA is always the same length, you can bind to an indexed value of it

    Here’s a rough example

    <!-- Assumes DataContext is ClassC -->
    <ListView ItemsSource="{Binding CollectionOfClassB}">
        <ListView.View>
            <GridView>
                <GridViewColumn DisplayMemberBinding="{Binding Id}" Header="ClassB.Id" />
                <GridViewColumn DisplayMemberBinding="{Binding CollectionOfClassA[0].Id}" Header="ClassA[0].Id" />
                <GridViewColumn DisplayMemberBinding="{Binding CollectionOfClassA[1].Id}" Header="ClassA[1].Id" />
            </GridView>
        </ListView.View>
    </ListView>
    

    If you have a dynamic number of columns, it becomes a bit trickier

    The simplest way would be to use a custom column and display the items in something like a horizontal StackPanel

    <!-- Assumes DataContext is ClassC -->
    <ListView ItemsSource="{Binding CollectionOfClassB}">
        <ListView.View>
            <GridView>
                <GridViewColumn DisplayMemberBinding="{Binding Id}" Header="ClassB.Id" />
                <GridViewColumn Header="CollectionOfA"
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <ItemsControl ItemsSource="{Binding CollectionOfClassA}">
                                <ItemsControl.ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsControl.ItemsPanelTemplate>
    
                                <ItemsControl.ItemTemplate>
                                    <TextBlock Text="{Binding Id}" Width="50" />
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
            </GridView>
        </ListView.View>
    </ListView>
    

    Of course, this doesn’t use the built-in GridView features like sorting

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

Sidebar

Related Questions

I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I am attempting to create a custom Adapter for my ListView since each item
Im attempting to create a new operator :? on lists, which operates the same
I am attempting to create a small application to collect data received from an
i'm attempting to create an header which is divided into 3 divs they will
I'm attempting to create a method in Haskell which I would think is very
I am attempting to create a linked server from a 2005 to 2008 Microsoft
I am attempting to create a custom server control CollapsablePanel that extends ASP.net's Panel.
I'm attempting to create a listview that binds dynamically to a set of dates.
I am attempting to bind a ObservableCollection to a ListView but when I attempt

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.