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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:49:28+00:00 2026-05-26T21:49:28+00:00

I’m trying to use two listviews (that are on same page – wpf) to

  • 0

I’m trying to use two listviews (that are on same page – wpf) to display info about a group class. In the first Listview I want to display the group # and group size(using gridview) and in the second listview I want to display the first name and last name of each person that is in the group that I have selected in the first listview box. Both listviews are using gridviews. I have one observableCollection that the first listview is binded to. Do I make another observablecollection to bind to the second listview. If so how do I connect the two collections? I cannot figure out how to do this. Any help is greatly greatly appreciated.

xaml:

   <ListView HorizontalAlignment="Stretch" Margin="0,12" x:Name ="listViewGroups" ItemsSource="{Binding Groups}" IsSynchronizedWithCurrentItem="{x:Null}" Grid.Column="1">
        <ListView.View>
            <GridView>
                <GridViewColumn DisplayMemberBinding="{Binding GroupNumber}" Width="40">
                    <GridViewColumnHeader Tag="GroupNumber" Content="#" Click="SortClick" />
                </GridViewColumn>
                <GridViewColumn DisplayMemberBinding="{Binding GroupLeader}" Width="120">
                    <GridViewColumnHeader Tag="GroupLeader" Content="Group Leader" Click="SortClick" />
                </GridViewColumn>
                <GridViewColumn DisplayMemberBinding="{Binding GroupSize}" Width="70">
                    <GridViewColumnHeader Tag="GroupSize" Content="Group Size" Click="SortClick" />
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>

            <Label Content="Leader" Height="28" Margin="12,12,0,0" Name="lblFirstName" Grid.Column="2" VerticalAlignment="Top" HorizontalAlignment="Left" />
            <TextBox Text="{Binding SelectedItem.GroupLeader, ElementName =listViewGroups}" Height="23" Margin="12,31,0,0" Name="txtFirstName" MaxWidth="160" Grid.Column="2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="160" />
            <Label Content="Group Members" Height="28" HorizontalAlignment="Left" Margin="14,60,0,0" Name="label1" VerticalAlignment="Top" Grid.Column="2" />
            <ListView HorizontalAlignment="Stretch" Margin="12,80,188,12" x:Name ="listViewGroupMembers" ItemsSource="{Binding Groups}"  IsSynchronizedWithCurrentItem="{x:Null}" VerticalAlignment="Stretch" Grid.Column="2">
                <ListView.View>
                    <GridView>
                        <GridViewColumn DisplayMemberBinding="{Binding FirstName}" Width="100">
                            <GridViewColumnHeader Tag="Name" Content="First Name" Click="SortClick" />
                        </GridViewColumn>
                        <GridViewColumn DisplayMemberBinding="{Binding LastName}" Width="80">
                            <GridViewColumnHeader Tag="Name" Content="Last Name" Click="SortClick" />
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>

Group Class:

public class Group
{

    public List<Camper> members;
    private String name;
    public static int groupCount = 0; 
    private static int optimalSize = 8;



    public string GroupNumber { get; set; }

    public string GroupLeader { get; set; }

    public int GroupSize { get; set; }

    public string FirstName { get { return "Testing"; } set { } }

    public string LastName { get; set; } 

    public Group()
    {        
        this.members = new List<Camper>();
        this.name = "Group " + groupCount;
        groupCount++;
    }
}

In the Mainwindow : this click event below has to do with a custom button that is on a toolbar i made. When I click the button Groups are customly made.

   ObservableCollection<Group> bind = new ObservableCollection<Group>();

    private void btnRun_Click(object sender, RoutedEventArgs e)
    {
        allGroups = AssignRelationshipValues.assignGroups(allCampers);
       ObservableCollection<Camper> groupCampers = new ObservableCollection<Camper>();

        bind.Groups.Clear();

        for (int g = 0; g < allGroups.Count; g++)
        {
            for (int i = 0; i < allGroups[g].members.Count; i++)
            {
                groupCampers.Add(allGroups[g].members[i]);

            } bind.Groups.Add(new Group { GroupNumber = allGroups[g].getName(), GroupSize = allGroups[g].getOptimalSize(), Members = groupCampers });

        } 
    }
  • 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-26T21:49:29+00:00Added an answer on May 26, 2026 at 9:49 pm

    If I’m reading this correctly, what you’d want is for your second ListView to be bound like so:

    <ListView ItemsSource="{Binding SelectedItem.members, ElementName=listViewGroups}" />
    

    Similar to what you have on your TextBox that’s bound to GroupLeader. Also, Shouldn’t FirstName and LastName be properties on the Camper class rather than on the Group class? They would have to be in order for this to work if I’m understanding what you’re after.

    Some clarification: What this binding is saying is “Go to the ‘listViewGroups’ ListView and get the SelectedItem“. This will be a Group object, since listViewGroups is bound to a collection of Group objects. Then it will try to find a property on the selected Group item called members, which is your List<Camper> – which you’ll probably want to change to an ObservableCollection. Then anything inside your second ListView will then reference the objects in the collection it’s bound to (Group.members) to resolve bindings, which means it will look for FirstName and LastName on the Camper objects within members.

    You can go here for further explanation from MSDN about Silveright/WPF databinding.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.