Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i have added picures to a List. I want to get 10 items from the list to populate my wpf list box. i have created a next and previous button. i have disabled the horizontal and vertical scrollbars on the listbox. I would like to display 10 items in the listbox and when i click the next button i would like the listbox to show the next 10 pictures from the list. When i press my previous button i would like to view previous 10 items in list. How can i achieve this? please can someone show me.
Posted
Comments
Vineeth P Joseph 2-Jul-10 0:49am    
hi,
could you please tell how to the data object looks like??
Abhinav S 2-Jul-10 15:37pm    
Post some code here - what have you tried till now.

The following will undoubtedly need some tweaking, but it should be close:

int m_itemCounter = 0;
bool TopOfList { get { return m_itemCounter == 0); } }
bool EndOfList { get { return m_itemCounter >= listBox.Items.Count; } }

private List<string> GetNItems(int count)
{
    List<string> results = new List<string>();
    int stop = Math.Min(count, this.listBox.Items.Count - m_itemCounter);
    for (int i = m_itemCounter; i < stop; i++)
    {
        results.Add(this.listBox.Items[i]);
    }
    m_itemCounter += stop;
    return results;
}
 
Share this answer
 
v2
Comments
tiggerc 2-Jul-10 10:01am    
Reason for my vote of 3
somewhere close
tiggerc 3-Jul-10 13:08pm    
Reason for my vote of 5
Undoubtedly the better example,
you could cheat and have a hidden control containing all pictures, create a start point variable to point to pic 1 then display in another listbox 1 - 10 of the hidden one, when user clicks next increase the start point variable to 11 and display 11-20 and so on, obviously clearing listview first.

I know it messy and I apologize before i get shot down in flames, depending on my target audience it would be one way.
 
Share this answer
 
Comments
#realJSOP 2-Jul-10 15:12pm    
You had the balls to vote my answer a 3, and you didn't even post any code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900