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 8242975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:21:05+00:00 2026-06-07T21:21:05+00:00

In my ViewModel I have a collection of objects which each contain another collection.

  • 0

In my ViewModel I have a collection of objects which each contain another collection. I am trying to display this in my View by using nested ListView ItemTemplates. Here is a simplification of my ViewModel code:

public ViewModelObject
{
    public ObservableCollection<OuterObject> OuterCollection { get; }
}

public OuterObject
{
    public string OuterTitle;
    public ObservableCollection<InnerObject> InnerCollection { get; }
}

public InnerObject
{
    public string InnerTitle;
}

And here is a simplification of how I’m trying to use this ViewModel in my XAML:

<ListView ItemsSource="{Binding OuterCollection}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding OuterTitle}"/>
                <ListView ItemsSource="{Binding InnerCollection}">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding InnerTitle}"/>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

If I remove the inner ListView, the outer ListView binding works perfectly fine. I just can’t figure out how to properly bind the inner collection object to the inner ListView. I’ve tried doing the inner binding with {Binding OuterCollection.InnerCollection}, {Binding DataContext.InnerCollection}, and {Binding RelativeSource={RelativeSource TemplatedParent}, Path=InnerCollection}, but all of these cause it to crash. What is the proper way to achieve this nested binding?

EDIT: I should add that this is for an application being ported from Windows Phone 7, and it is an attempt to find a replacement for LongListSelector, which is not available in WinRT.

  • 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-07T21:21:06+00:00Added an answer on June 7, 2026 at 9:21 pm

    I figured out the solution! It required a combination of my previously attempted solutions. The correct binding for the internal collection in a nested ListView is:

    {Binding RelativeSource={RelativeSource TemplatedParent},
                             Path=DataContext.InnerCollection}
    

    Also, depending on your purpose for the nested ListViews, I found it better to use an ItemsView for the outer collection and a ListView for the inner collection. Otherwise, the selectability of the two controls overlap each other.

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

Sidebar

Related Questions

I have a complex view model which contains a collection of other objects which
I have a collection of objects, each of which holds a set of name-value
I am trying to implement Repository pattern in JavaScript. I have ViewModel which i
I have a viewmodel which is subscribing to the event NavigationCompletedEvent. This viewmodel need
I have a observable collection of viewmodel objects. How can I subscribe to the
I have a view model with a collection of other objects in it. public
I'm trying to display a list of Notes. I have an ItemsControl which is
I have got a collection of viewModels(InputViewModel) in an other viewModel(ScenarioManager). each InputviewModel has
I have a collection of picture Objects for which I need to download thumbs
Say I have a TabControl that is presenting a collection of Foo objects (each

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.