JSONファイルをリストボックスに解析しようとしていますが、その方法がわからず、ここや他の場所で例を理解するのに苦労しています。
現在、私は次のものを持っています:
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
    }
JSONファイルは正しく解析され、あちこちでデータを取得できますが、それらをすべて1つのリストボックスにまとめる方法がわかりません。
私がやろうとしているのは、JSONの「TITLE」の横にJSONの「IMAGE」を表示するリストボックスを作成することです。それらをクリックすると、最終的には他のすべての情報を含む新しいページに移動するはずです。これを理解すると、QueryStringsなどを介してすべての断片を渡すことができる可能性があります。
誰かが私の最後のビットが理にかなっていることを確認し、リストボックスの正しい方向に私を向けることができれば、私はそれを感謝します。