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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:19:14+00:00 2026-06-14T15:19:14+00:00

Tell me pls how to implement automatically loadable listBox. When scrolling down elements should

  • 0

Tell me pls how to implement automatically loadable listBox. When scrolling down elements should be added to the previous one. Unfortunately the examples of such list I have not found, I saw that in the network are advised to use ObservalableCollection, but I don’t understand how to add elements to the collection. Here is my ample test application.

I need to connect to web-service and coming from the xml parsing. Here an example of work with Web service if request like this http://beta.sztls.ru/mapp/eps/?count=10 the service constructs xml with the latest ten news, on such a request http://beta.sztls.ru/mapp/eps/?count=10&skip=10, it returns the xml with the following ten news
I have a class

public class Item
    {
        public string Description { get; set; }
        public string Title { get; set; }
        public string Image { get; set; }
    }

And in code-behind

public partial class MainPage : PhoneApplicationPage
    {
        private ObservableCollection<Item> _collection;
        public ObservableCollection<Item> Collection
        {
            get
            {
                if (_collection == null)
                {
                    _collection = new ObservableCollection<Item>();
                }
                return _collection;
            }
        }

        private int endIndex = 0;

        // Конструктор
        public MainPage()
        {
            InitializeComponent();
            this._collection = new ObservableCollection<Item>();

            this.listBox1.ItemsSource = Collection;
            this.listBox1.Loaded += new RoutedEventHandler(listBox1_Loaded);

        }

        void listBox1_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                LoadItems(10);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.StackTrace);

            }
        }

        private void LoadItems(int count)
        {
            WebClient webClient = new WebClient();
            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
            webClient.DownloadStringAsync(
                new Uri(String.Format("http://beta.sztls.ru/mapp/eps/" + "?count={0}" + "&skip={1}" + "&ticks={2}",
                                      count, this.endIndex, DateTime.Now.Ticks)));
                 this.endIndex+=count
        }

        void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                ParseResult(e.Result);
            }
        }

        private void ParseResult(string result)
        {
            XElement element = XElement.Parse(result);



            var res = from part in element.Descendants("news")
                      select new Item
                                 {
                                     Image = part.Element("image_url").Value,
                                     Title = part.Element("title").Value,
                                     Description = part.Element("description").Value
                                 };

           //Here,as far as I understand, I need like this Collection.Add(res)
        }
    }

in Xaml

<toolkit:LongListSelector Grid.Row="1" IsFlatList="True" x:Name="listBox1">
                <toolkit:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding Image}" Width="100" Height="100"/>
                            <StackPanel>
                                <TextBlock Text="{Binding Title}" FontSize="22" Foreground="Red"/>
                                <TextBlock Text="{Binding Decription}" FontSize="26" Foreground="Blue"/>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>

                </toolkit:LongListSelector.ItemTemplate>
                <toolkit:LongListSelector.ListFooterTemplate>
                    <DataTemplate>
                        <TextBlock x:Name="footer"/>
                    </DataTemplate>
                </toolkit:LongListSelector.ListFooterTemplate>
            </toolkit:LongListSelector>

And how do I keep track of the time when I should send a request for load new items?

Thanks in advance for your help and sorry for my English. I have used http://www.bing.com/translator =)

  • 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-14T15:19:15+00:00Added an answer on June 14, 2026 at 3:19 pm

    Alright. If I understood everything correctly, you want to generate a collection of items from the xml file.
    I suppose, the best option for you is to create an entity class with the fields “Image”, “Title”, “Description” e.t.c.(you’ve already done it) and in your ParseResult() method create a collection of this Entity. It will look like:

    List<Entity> list = ParseResult(xdoc);
    

    where in ParseResult you get the data from xml file with some expression, like:

    return (from node in xdoc.Descendants("something") select new Entity(node.Attribute("Title").Value, node.Attribute("Image").Value,... ).ToList();
    

    Now you’ll have a collection of items. What do you want to do with them next? I suppose, create a UI, using it. I suppose, there would be some controls, which are generated using this collection. So, if you want to update this page and add some new controls, you should check, which ones are already added to the page. In this case I would prefer to create a field in user control, which would check this. It should be unique, so let’s make it “title”.(it seems that “title” is unique in these documents) So, when you want to add a control on your page, you should check if none of the controls has the same “title” as the one, you want to add.

    Hope, I understood all correct.


    Alexandr, you just need a constructor for your item entity, like

    public Item(string desc, string title, string image)
            {
                this.Description = desc;
                this.Title = title;
                this.Image = image;
            }
    

    Then you could fill the list much easier:

    List<Item> list = (from node in xdoc.Descendants("news") select new Item(node.Element("description").Value, node.Element("title").Value, node.Element("image_url").Value)).ToList();
    

    That should work.

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

Sidebar

Related Questions

can some one pls tell me how to get the 'schema name' for a
I'm trying to pass context from one class to another.. pls tell me wat
Can anybody pls tell me, how can i make a AJAX request and send
tell me the examples of both the iPhone development programs. 1)Standard Program and 2)Enterprise
I'm trying to copy SQL database from one server to another. Please tell me
Is it possible to make httpService Requests synchronous in Flex? if yes pls tell
Can anyone pls tell me that, why I can't use normal C++ classes within
I am getting undefined method `member' error in my following code Pls tell where
pls tell me in which version dynamic keyword is introduced ? I found strange
can someone pls tell me how can i execute my HelloWorld.java in apache hadoop

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.