C# 如何在c中向listbox添加多个itemsources

C# 如何在c中向listbox添加多个itemsources,c#,json,windows,listbox,C#,Json,Windows,Listbox,我正在尝试将多个itemsources添加到我的列表框“lstShow”。这是我的xaml: private void w_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (!string.IsNullOrEmpty(e.Result)) { //Parse JSON result as POCO var root1 = JsonCo

我正在尝试将多个itemsources添加到我的列表框“lstShow”。这是我的xaml:

private void w_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{

    if (!string.IsNullOrEmpty(e.Result))
    {
        //Parse JSON result as POCO 
        var root1 = JsonConvert.DeserializeObject<RootObject>(e.Result);
        var root2 = JsonConvert.DeserializeObject<Headline>(e.Result);
        lstShow.ItemsSource = root1.headlines;
       // lstShow.ItemsSource = root2.images;
    }
}
问题是我不能将多个itemsources添加到我的列表框中。我想将root1和root2添加到我的列表框中。请帮忙,谢谢

<ListBox x:Name="lstShow" FontFamily="Arial Black" VerticalAlignment="Center" Margin="-6,0,0,-26" Height="610" RenderTransformOrigin="0.5,0.5" Background="{x:Null}" Opacity="0.8">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Button  Style="{StaticResource ButtonStyle1}" Tag="{Binding News}" Width="450" Height="Auto" Background="Black" BorderBrush="Transparent" FontWeight="Bold" FontSize="23" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,5" Opacity="0.95" Click="news_click" Foreground="White">
                    <StackPanel>
                        <Image Source="{Binding url}" Height="100" Width="200"/>
                    <TextBlock  TextWrapping="Wrap" FontFamily="Segoe WP Black" Foreground="White" FontSize="18" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TextAlignment="Left" Width="350" Height="150">
                        <Run FontSize="23" Text="{Binding headline}" />
                        <LineBreak/>
                        <Run Text="{Binding description}" FontWeight="Normal" FontSize="16" FontFamily="Segoe WP SemiLight"/>
                        </TextBlock>
                    </StackPanel>
                </Button>
              </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
}

}

我想从RootObject中添加列表“标题”,并将“类别”从标题中添加到列表框中。

您没有显示Category类,因此我将假装它是这样的:

public class RootObject
{
public string timestamp { get; set; }
public int resultsOffset { get; set; }
public string status { get; set; }
public int resultsLimit { get; set; }
public int resultsCount { get; set; }
public List<Headline> headlines { get; set; }
您可以从标题中选择所需的所有字段,然后展开类别列表:

public class Category
{
    public string Name { get; set; }
    public int Id { get; set; }
}

@GrantWinney是的,我想将两个列表的全部内容转储到列表框中。我已经编辑了我的问题。有什么建议吗?
public class Category
{
    public string Name { get; set; }
    public int Id { get; set; }
}
var ro = root1.headlines.Select(x => new
         {
             x.byline,
             x.description,
             x.lastModified,
             ...
             ...
             categories = string.Join(", ", x.categories.Select(y => y.Name))
         }).ToList();