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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:52:52+00:00 2026-06-17T15:52:52+00:00

I have two viewmodels with an observablecollection in each viewmodel. These collection have an

  • 0

I have two viewmodels with an observablecollection in each viewmodel.
These collection have an relation to each other.
For instance let say one is a collection of ClassA that have an Id and a Name the other is a collection of ClassB that has an ClassAId and some OtherValue
Is it possible to databind these to a ListView so that for each item in CollectionA the OtherValue is fetched from CollectionB

   <ListView ItemsSource="{Binding ViewModelA.CollectionClassA}">
       <ListView.View>
          <GridView>                            
            <GridViewColumn DisplayMemberBinding="{Binding Path=ClassA.Name}"/>
            <GridViewColumn DisplayMemberBinding="{Binding Path=ClassB.OtherValue}"/>
          </GridView>
         </ListView.View>
    </ListView>

I hope I didn’t confuse you to much with my explanation of my question:)

  • 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-17T15:52:53+00:00Added an answer on June 17, 2026 at 3:52 pm

    You’re best option is to return a new collection that is formed at the view-model level based upon a new view-model (or model) that is special to that collection:

    public class OtherViewModel
    {
        //Expand these if you want to make it INPC
        public int Id { get; private set; }
        public string Name { get; private set; }
        public Foo OtherValue { get; private set; }
    }
    
    public class MainViewModel
    {
        // Somewhere in MainViewModel, create the collection
        ObservableCollection<OtherViewModel> CreateCollection(ICollection<ClassA> a, ICollection<ClassB> b)
        {
            var mix = a.Join(b, a => a.Id, b => b.Id,
                (a, b) => new OtherViewModel { Id = a.Id, Name = a.Name, OtherValue = b.OtherValue });
    
            return new ObservableCollection<OtherViewModel>(mix);
        }
    
        // Expose the collection (possibly INPC if needed)
        public ObservableCollection<OtherViewModel> MixedCollection { get; private set; }
    }
    

    XAML:

    <!-- Assuming the DataContext is MainViewModel -->
    <ListView ItemsSource="{Binding MixedCollection}">
      <ListView.View>
        <GridView>                            
          <GridViewColumn DisplayMemberBinding="{Binding Path=Name}"/>
          <GridViewColumn DisplayMemberBinding="{Binding Path=OtherValue}"/>
        </GridView>
      </ListView.View>
    </ListView>
    

    Caveats:

    • You can choose to use ObservableCollection<T> or not, it’s up to you if you need this collection to be observable.
    • You can also expand your view-model to subscribe to the ClassA and ClassB collections so that it can update your main collection when they either of them change.

    Either way, this should give you a good idea of the direction to go in, with some minor adjustments to fit into your code.

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

Sidebar

Related Questions

I have a base viewModel and two derived viewModels from it. In my base
I have two ViewModels that present the same Model to different Views. One presents
We have two WebApplication in one MVC solution, one for Desktop and the other
I have two ViewModels in my MVVM app. the one is bind to main
I have two ViewModels which are similar, and i need to cast one to
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
I have two columns say Main and Sub . (they can be of same
I have two tables, lets say table1 and table2 with common columns, id and
I have a ViewModel, it takes two parameters in the constructor that are of

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.