简体   繁体   中英

Move data from itemsource of one listbox to another listbox wp8

I am parsing a RSS Feed from one site and storing it in listbox1 and then parsing another RSS storing it in listbox2 . Now I want to combine the data of listbox1 and listbox2 in listbox3 . It might sound silly but I am unable to do it. The main problem is I am not able to access the controls inside the listbox.

<ListBox x:Name="list1" ItemsSource="{Binding RSSData}" DataContext="{Binding RSSData}" Visibility="Collapsed">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock HorizontalAlignment="Center"  x:Name="txtpubDate" Foreground="#FF170505"  Text="{Binding Path=pubDate}" TextDecorations="Underline" ></TextBlock>
                <TextBlock Padding="18" Foreground="#FF0E0101" x:Name="txtTitle"  TextWrapping="Wrap" Text="{Binding Path=Title}" FontWeight="Bold"></TextBlock>
                <Image Height="200"  x:Name="imageLink"   Source="{Binding strImg}"></Image>
                <TextBlock Foreground="#FF0F0202" Padding="35" TextTrimming="WordEllipsis" HorizontalAlignment="Left" x:Name="txtDesc" Margin="2"  TextWrapping="Wrap" Text="{Binding Path=Description,Converter={StaticResource RssTextTrimmer}}"></TextBlock>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

This is the XAML code of my listbox1 and I am trying to do it with listbox3.itemsource=listbox1.itemsource; but nothing is happening.

I also tried to add data in this way: listbox3.items.add(listbox.items[i]) but nothing is working.

Please help.

You can loop through the contents of the listbox and add them one by one for instance:

foreach(object item in listbox1.items)
{
   listbox3.items.add(item);
}

and then do the same for listbox2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM