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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:40:30+00:00 2026-05-31T08:40:30+00:00

Hi all i seem to be stuck with this, i can get it display

  • 0

Hi all i seem to be stuck with this, i can get it display the first item in the array but not the whole list

 var actor = xmlInfo
         .Descendants("person")
            .Where(x => x.Attribute("job").Value == "Actor")
            .Select(x => x.Attribute("name").Value)
         .ToArray();

my listbox is the following

 ThirdListBox.ItemsSource = from info in xmlInfo.Descendants("movies")
                                   select new MovieInfo

                                   {
                                       tagline = info.Element("movie").Element("tagline").Value,
                                       castDirector = director[0],
                                       castActor = actor[0],
                                   };

xaml is

<ListBox Name="ThirdListBox" Margin="0,-24,-12,0" ItemsSource="{Binding Items}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,-12,0" Width="432" Height="800"  Background="#82101010">
                           <TextBlock Text="{Binding tagline}" TextWrapping="Wrap" FontSize="30" DataContext="{Binding}" />
                            <TextBlock Text="{Binding castDirector}" TextWrapping="Wrap" FontSize="30" DataContext="{Binding}" />
                            <TextBlock Text="{Binding castActor}" TextWrapping="Wrap" FontSize="30" DataContext="{Binding}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

sample xml

<movies>
  <movie>
    <translated>true</translated>
    <adult>false</adult>
    <language>en</language>
    <original_name>Batman</original_name>
    <name>Batman</name>
    <alternative_name>Batman (1989)</alternative_name>
    <type>movie</type>
    <id>268</id>
    <imdb_id>tt0096895</imdb_id>
    <url>http://www.themoviedb.org/movie/268</url>
    <overview></overview>
    <votes>30</votes>
    <rating>8.1</rating>
    <tagline></tagline>
    <certification>PG-13</certification>
    <released>1989-06-23</released>
    <runtime>126</runtime>
    <budget>35000000</budget>
    <revenue>413200000</revenue>
    <homepage/>
    <trailer>http://www.youtube.com/watch?v=HlsM2_8u_mk</trailer>
    <categories></categories>
    <keywords></keywords>
    <studios></studios>
    <languages_spoken></languages_spoken>
    <countries></countries>
    <images></images>
    <cast>
      <person name="Tim Burton" character="" job="Director" id="510" thumb="http://cf2.imgobject.com/t/p/w185/oKucd7g8BpfWGw8bDRLkwxa7bT1.jpg" department="Directing" url="http://www.themoviedb.org/person/510" order="0" cast_id="1"/>
      <person name="Bob Kane" character="" job="Characters" id="3794" thumb="http://cf2.imgobject.com/t/p/w185/uh9ILSkz0iCQ8o1Ljnz6ubYMvOD.jpg" department="Writing" url="http://www.themoviedb.org/person/3794" order="0" cast_id="2"/>
      <person name="Anton Furst" character="" job="Production Design" id="3807" thumb="" department="Art" url="http://www.themoviedb.org/person/3807" order="0" cast_id="22"/>
      <person name="Peter Guber" character="" job="Producer" id="3804" thumb="" department="Production" url="http://www.themoviedb.org/person/3804" order="0" cast_id="16"/>
      <person name="Marion Dougherty" character="" job="Casting" id="3806" thumb="" department="Production" url="http://www.themoviedb.org/person/3806" order="0" cast_id="21"/>
      <person name="Ray Lovejoy" character="" job="Editor" id="244" thumb="" department="Editing" url="http://www.themoviedb.org/person/244" order="0" cast_id="20"/>
      <person name="Danny Elfman" character="" job="Original Music Composer" id="531" thumb="http://cf2.imgobject.com/t/p/w185/pWacZpYPos8io22nEiim7d3wp2j.jpg" department="Sound" url="http://www.themoviedb.org/person/531" order="0" cast_id="19"/>
      <person name="Roger Pratt" character="" job="Director of Photography" id="293" thumb="" department="Camera" url="http://www.themoviedb.org/person/293" order="0" cast_id="18"/>
      <person name="Jon Peters" character="" job="Producer" id="3805" thumb="" department="Production" url="http://www.themoviedb.org/person/3805" order="0" cast_id="17"/>
      <person name="Warren Skaaren" character="" job="Screenplay" id="913" thumb="" department="Writing" url="http://www.themoviedb.org/person/913" order="0" cast_id="3"/>
      <person name="Sam Hamm" character="" job="Screenplay" id="3795" thumb="" department="Writing" url="http://www.themoviedb.org/person/3795" order="0" cast_id="23"/>
      <person name="Michael Keaton" character="Batman" job="Actor" id="2232" thumb="http://cf2.imgobject.com/t/p/w185/jSG7yQxSsGzz1TbDjq0811W5LK4.jpg" department="Actors" url="http://www.themoviedb.org/person/2232" order="0" cast_id="4"/>
      <person name="Jack Nicholson" character="Joker" job="Actor" id="514" thumb="http://cf2.imgobject.com/t/p/w185/xr1kLWa28vOzdfzsdmxG74q9asp.jpg" department="Actors" url="http://www.themoviedb.org/person/514" order="1" cast_id="5"/>
      <person name="Kim Basinger" character="Vicki Vale" job="Actor" id="326" thumb="http://cf2.imgobject.com/t/p/w185/kNNGFpfEr71nDUfzdVxklamI5nH.jpg" department="Actors" url="http://www.themoviedb.org/person/326" order="2" cast_id="6"/>
      <person name="Michael Gough" character="Alfred" job="Actor" id="3796" thumb="http://cf2.imgobject.com/t/p/w185/lSADK0gjUtcq4B6zKIUwB3SofSP.jpg" department="Actors" url="http://www.themoviedb.org/person/3796" order="3" cast_id="7"/>
      <person name="Pat Hingle" character="Commissioner James Gordon" job="Actor" id="3798" thumb="http://cf2.imgobject.com/t/p/w185/wonbnphqVPITaC25uC698Du4tuj.jpg" department="Actors" url="http://www.themoviedb.org/person/3798" order="4" cast_id="8"/>
      <person name="Billy Dee Williams" character="Harvey Dent" job="Actor" id="3799" thumb="http://cf2.imgobject.com/t/p/w185/9kaLGHdD8UXvoI7W6z2hrGQyU2r.jpg" department="Actors" url="http://www.themoviedb.org/person/3799" order="5" cast_id="9"/>
      <person name="Jack Palance" character="Carl Grissom" job="Actor" id="3785" thumb="http://cf2.imgobject.com/t/p/w185/RKqKZ2rRDNkv0jaQscDARfRh9D.jpg" department="Actors" url="http://www.themoviedb.org/person/3785" order="6" cast_id="10"/>
      <person name="Jerry Hall" character="Alicia Grissom" job="Actor" id="3800" thumb="" department="Actors" url="http://www.themoviedb.org/person/3800" order="7" cast_id="11"/>
      <person name="Tracey Walter" character="Bob the Goon" job="Actor" id="3801" thumb="http://cf2.imgobject.com/t/p/w185/pMeImyAZ8fpQ32QyPO8g6W8gs13.jpg" department="Actors" url="http://www.themoviedb.org/person/3801" order="8" cast_id="12"/>
      <person name="Lee Wallace" character="Mayor" job="Actor" id="3802" thumb="" department="Actors" url="http://www.themoviedb.org/person/3802" order="9" cast_id="13"/>
      <person name="William Hootkins" character="Eckhardt" job="Actor" id="663" thumb="http://cf2.imgobject.com/t/p/w185/vrWs2YAhbLuq6YNcUa5IHGQGP7r.jpg" department="Actors" url="http://www.themoviedb.org/person/663" order="10" cast_id="14"/>
      <person name="Edwin Craig" character="Rotelli" job="Actor" id="3803" thumb="" department="Actors" url="http://www.themoviedb.org/person/3803" order="11" cast_id="15"/>
      <person name="Robert Wuhl" character="Alexander Knox" job="Actor" id="4040" thumb="http://cf2.imgobject.com/t/p/w185/7bboXtHrq8qOtQBdcZko3KJfFyH.jpg" department="Actors" url="http://www.themoviedb.org/person/4040" order="12" cast_id="24"/>
    </cast>
    <version>1242</version>
    <last_modified_at>2012-03-10 12:14:40 UTC</last_modified_at>
  </movie>
</movies>

so what i am looking to do is display all actors in my listbox

thanks

  • 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-31T08:40:31+00:00Added an answer on May 31, 2026 at 8:40 am

    So, I think based on what you’ve said, you’re going to have to change a few things. First off, if you want to display a list of lists, you’re not going to be able to do it by binding to textboxes. Here’s a way to set it up. I know this isn’t exactly what you’re asking, but it might get you in the right direction.

    A couple caveats:

    1. Don’t use a ListBox unless you need a ListBox. ItemsControl works great if you don’t need to select an item from the list.

    2. I’m not 100% sure what you’re trying to get, so this is my best guess at what you ultimately want to see. If it isn’t quite there, let me know, and I’ll see if I can tweak it some more.

    In your DataContext’s class (e.g. ViewModel):

        public ObservableCollection<Movie> Items { get; set; }
    
        public MainViewModel()
        {
            XDocument xmlInfo = XDocument.Load(@"c:\temp\Xmlfile1.xml");
    
    
            var items = xmlInfo.Descendants("movie")
                            .Select(x => new Movie
                                             {
                                                 MovieName = x.Element("name").Value, 
                                                 Actors = x.Descendants("person").Where(p => p.Attribute("job").Value == "Actor").Select(a=>a.Attribute("name").Value).ToList(),
                                                 Directors = x.Descendants("person").Where(p => p.Attribute("job").Value == "Director").Select(a => a.Attribute("name").Value).ToList()
                                             });
    
            Items = new ObservableCollection<Movie>(items);
    
    
    
        }
    

    Movie is defined as:

    public class Movie
    {
        public string MovieName { get; set; }
        public List<string> Actors { get; set; }
        public List<string> Directors { get; set; }
    
    }
    

    Then, the XAML is defined as:

        <ListBox ItemsSource="{Binding Items}">
    
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding MovieName}" FontSize="32"/>
                        <StackPanel Orientation="Horizontal">
                            <ListBox ItemsSource="{Binding Actors}" Margin="5"/>
                            <ListBox ItemsSource="{Binding Directors}" Margin="5"/>
                        </StackPanel>
                    </StackPanel>
    
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    

    Which yields:

    enter image description here

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

Sidebar

Related Questions

All the ways I can think to do this seem very hackish. What is
I cannot seem to get this date picker working at all. I know it
I been working on this code for a while and can't seem to get
I hope this is a simple one, but I can't seem to be able
All the examples seem to want the Ninject.Web.Common file reference. I can NuGet Ninect
I've searched all over the web and can't seem to find documentation or even
I have been stuck on this all weekend and failed miserably! Please help me
First of all I apologize in advance for this question, a bit off the
I'm really sorry. This must seem like an incredibly stupid question, but unless I
I'm stuck at this part... I'm trying to get the ID to be included

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.