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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:25:24+00:00 2026-06-14T22:25:24+00:00

I’m attempting to parse a JSON file into a ListBox, but I have no

  • 0

I’m attempting to parse a JSON file into a ListBox, but I have no idea how to do so and have been having difficulty understanding examples here and elsewhere.

Currently, I have the following:

XAML

<controls:Pivot Title="Episode Guide">
        <!--Pivot item one-->
        <controls:PivotItem Header="season 1">
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <ListBox x:Name="Season1Box" Margin="0,0,0,0" VerticalAlignment="Top" Height="607" SelectionChanged="Season1Box_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                                <Image Source="{Binding Path=image1}"/>
                                <TextBlock Text="{Binding Path=title1}" TextWrapping="Wrap" Margin="10,10,0,0" FontSize="25" Foreground="White" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </controls:PivotItem>

        <!--Pivot item two-->
        <controls:PivotItem Header="season 2">
            <Grid x:Name="ContentPanel2" Grid.Row="1" Margin="12,0,12,0">
                <ListBox x:Name="Season2Box" Margin="0,0,0,0" VerticalAlignment="Top" Height="607" SelectionChanged="Season2Box_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                                <Image Source="{Binding Path=image2}"/>
                                <TextBlock Text="{Binding Path=title2}" TextWrapping="Wrap" Margin="10,10,0,0" FontSize="25" Foreground="White" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </controls:PivotItem>

        <controls:PivotItem Header="season 3">
            <Grid x:Name="ContentPanel3" Grid.Row="1" Margin="12,0,12,0">
                <ListBox x:Name="Season3Box" Margin="0,0,0,0" VerticalAlignment="Top" Height="607" SelectionChanged="Season3Box_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                                <Image Source="{Binding Path=image3}"/>
                                <TextBlock Text="{Binding Path=title3}" TextWrapping="Wrap" Margin="10,10,0,0" FontSize="25" Foreground="White" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </controls:PivotItem>
    </controls:Pivot>

C#

private void EpisodeGuideStream()
    {
        var client = new WebClient();
        client.OpenReadCompleted +=
            (s, eargs) =>
            {
                var serializer = new DataContractJsonSerializer(typeof(RootObject));
                if (eargs.Error != null)
                {
                    if (eargs.Error.Message.Contains("NotFound"))
                    {
                        MessageBox.Show("Could not retrieve episode guide", "Error", MessageBoxButton.OK);
                    }
                    else
                    {
                        MessageBox.Show("Could not retrieve episode guide", "Error", MessageBoxButton.OK);
                    }
                }
                else
                {
                    var episodeGuide = (RootObject)serializer.ReadObject(eargs.Result);

                    //I have no idea what I'm doing (Part 1)
                    List<string> episode1 = new List<string>();
                    List<string> title1 = new List<string>();
                    List<string> director1 = new List<string>();
                    List<string> writer1 = new List<string>();
                    List<string> airdate1 = new List<string>();
                    List<string> sypnosis1 = new List<string>();
                    List<string> image1 = new List<string>();

                    foreach (var obj in episodeGuide.SEASON1)
                    {
                        //I have no idea what I'm doing (Part 2)
                        episode1.Add(obj.EPISODE);
                        title1.Add(obj.TITLE);
                        director1.Add(obj.DIRECTOR);
                        writer1.Add(obj.WRITER);
                        airdate1.Add(obj.AIRDATE);
                        sypnosis1.Add(obj.SYPNOSIS);
                        image1.Add(obj.IMAGE);

                  //      Season1Box.ItemsSource = figure out what goes here;
                    }
                    foreach (var obj2 in episodeGuide.SEASON2)
                    {
                        //          populate Season2Box
                    }
                    foreach (var obj3 in episodeGuide.SEASON3)
                    {
                        //          populate Season3Box
                    }



                }
            };
        var uri = new Uri(jsonfile);
        client.OpenReadAsync(uri);
    }

    public class SEASON1
    {
        public string EPISODE { get; set; }
        public string TITLE { get; set; }
        public string DIRECTOR { get; set; }
        public string WRITER { get; set; }
        public string AIRDATE { get; set; }
        public string SYPNOSIS { get; set; }
        public string IMAGE { get; set; }
    }

    public class SEASON2
    {
        public string EPISODE { get; set; }
        public string TITLE { get; set; }
        public string DIRECTOR { get; set; }
        public string WRITER { get; set; }
        public string AIRDATE { get; set; }
        public string SYPNOSIS { get; set; }
        public string IMAGE { get; set; }
    }

    public class SEASON3
    {
        public string EPISODE { get; set; }
        public string TITLE { get; set; }
        public string DIRECTOR { get; set; }
        public string WRITER { get; set; }
        public string AIRDATE { get; set; }
        public string SYPNOSIS { get; set; }
        public string IMAGE { get; set; }
    }

    public class RootObject
    {
        public List<SEASON1> SEASON1 { get; set; }
        public List<SEASON2> SEASON2 { get; set; }
        public List<SEASON3> SEASON3 { get; set; }
    }

    private void Season1Box_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //To eventually navigate to another page
    }

    private void Season2Box_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //To eventually navigate to another page
    }

    private void Season3Box_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //To eventually navigate to another page
    }

The JSON file is parsed correctly and I can retrieve bits of data here and there, but I have no clue how to put them all together into one ListBox.

What I’m attempting to do is to have a ListBox that shows the “IMAGE” from the JSON next to the “TITLE” from the JSON. Clicking them should eventually navigate to a new page with all the other information, I could potentially pass all the bits and pieces through QueryStrings or something once I figure this out.

If someone could check to see that my last bit makes sense and point me in the right direction for the ListBox I’d appreciate it.

  • 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-14T22:25:25+00:00Added an answer on June 14, 2026 at 10:25 pm
    1. You should get rid of the SEASON2 and SEASON3 classes, and rename SEASON1 to Episode. The class-names are not used in the serialization. You should also change the IMAGE-property to type Uri, so you can bind it to an image.

      public class Episode
      {
          public string EPISODE { get; set; }
          public string TITLE { get; set; }
          public string DIRECTOR { get; set; }
          public string WRITER { get; set; }
          public string AIRDATE { get; set; }
          public string SYPNOSIS { get; set; }
          public Uri IMAGE { get; set; }
      }
      
      public class RootObject
      {
          public List<Episode> SEASON1 { get; set; }
          public List<Episode> SEASON2 { get; set; }
          public List<Episode> SEASON3 { get; set; }
      }
      
    2. You can bind (or assign) the list to a ListBox’s ItemsSource property, and it will get populated with rows based on the objects in the list. Each list item uses their corresponding object as a DataContext, and you can bind to their properties.

      Season1Box.ItemsSource = root.SEASON1;
      Season2Box.ItemsSource = root.SEASON2;
      Season3Box.ItemsSource = root.SEASON3;
      
    3. To bind a control’s attribute to an object property, you can use the syntax Text="{Binding Path=MyProperty}". You can even address nested propertes, like MyProperty.OtherProperty.

      <ListBox.ItemTemplate>
          <DataTemplate>
              <StackPanel Orientation="Horizontal" Margin="0,0,0,0">
                  <Image Source="{Binding Path=IMAGE}"/>
                  <TextBlock Text="{Binding Path=TITLE}" TextWrapping="Wrap" Margin="10,10,0,0" FontSize="25" Foreground="White" />
               </StackPanel>
           </DataTemplate>
       </ListBox.ItemTemplate>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
This could be a duplicate question, but I have no idea what search terms
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have been unable to fix a problem with Java Unicode and encoding. The
I have a reasonable size flat file database of text documents mostly saved in
i want to parse a xhtml file and display in UITableView. what is the

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.