I have a Long List Selector. when page loading first then it has 10 items in the list, when user scroll down the list and when he reach to the bottom of the list then I want to add 10 items to the list.
I tried lot of methods to catch the end of the scroll but can't find any event for it in WP8.
You can use event ItemRealized on Longlistselector or
Try this
http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/10/01/how-to-create-an-infinite-scrollable-list-with-longlistselector.aspx
There is no magic. The trick is same that you tried. I.e. You need to listen to a specific event and load the next 10 item. For a detail code example see this
Related
I am having trouble getting code to fire when a listview has items reordered. I created an event handler for collectionchanged, but that fires when an item is added. I want it only to fire when it is reordered, but reordered in Winrt is a combination of remove and add.
The more general idea of what I want to do is create two listviews of items, where the first listview's items rearrange if corresponding items in the second listview are reordered by the user using drag and drop. I'm pretty close to getting it to work. I have id numbers for elements in both lists.
First, make sure you are using an observable collection.
Second, read this: XAML/C#: What event fires after reordering a gridview?
Best of luck!
In my windows phone 8 application, I've used Long List Selector. When the user clicks on the show button in Main Page, I'm getting the result from the server and setting those results to Long List Selector, which is in Results Page. Up to this, everything is fine.
pageNumber = 1;
noOfResultsPerPage = 15;
Now, I want to add next 15 records to the Long List Selector when the user reaches to the last item. How should I know whether user scrolled to the last item in the list or not?
So that we can send the request to the server and get the records from the server and add to the list.
Thanks
If i'm right you want to implement incremental loading in the longlistselector, then you can use the itemrealized event of longlistseletor, there is a very nice sample which i would suggest you to have a look
You need to subscribe to ItemRealized event (this event is raised each time an item is rendered on the screen) So when the ItemRealized is raised you have to check the index of the iteam realized and then execute your method
I'm doing one windows phone 8 application. In this I've used list box. For the very first page I'm getting the data from server and adding that data to list box. Now I want to add Show More at the bottom of the list box i.e after the last item, to get the next items from the server.
How could I achieve this?
Hear you have to use Horizontal scrolling for load next data
Check below tutorial
Detect when a ListBox scrolls to its end (WP7)
Windows phone tutorial:Listbox
WP7 – How To Extend ListBox When Reaching Last Item
Windows Phone 7 ListBox Pagination with MVVMLight & ApplicationBar
we can Gets or sets the amount of data to fetch for virtualizing/prefetch operations by using
ListViewBase.DataFetchSize property and can Initiates the asynchronous request to load more data items, in accordance with the active incremental loading settings by ListViewBase.LoadMoreItemsAsync method.
If you want to do it by pagination then the following links may be helpfull for you
DataFetchSize method
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.listviewbase.datafetchsize.aspx
LoadMoreItemsAsync method:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.listviewbase.loadmoreitemsasync.aspx
You can see examples of using these here (though note that the sample was based on Windows 8 BUILD release and the apis have had some changes)
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/e71b7036-4fb7-4963-a65d-5bcb9fd8f664
I'll go ahead posting the logic as My code might not match with yours
So
1 -> Save the server data in an array or a list.
2 -> Design the xaml in a way that the Parent Grid has two or more rows with the last row for the show more. And the one before for the list. (Adjust height accordingly)
3 -> Populate it with a limited amount of data.
4 -> Next use the ListBox.Items.Add(data) method to add the data to the list. Keep sorted property off so that the elements are inserted at the bottom of the list
-> Go through the link Add Method for Observable Collections
Use step four on the show more button click .. and also adjust the height of the list or put it into a scrollviewer so that limited height scrolling can be done . olease update if further queries
I have two different HTML files, two different UIWebViews & a UISegmentControl. On segmentChanged, I had displayed the WebView by loading a HTML file.
Both HTML files contains common sections only the section content is changed. Now I want to implement the functionality that, when user reads section 1.1 of first WebView & clicks Segment for loading second WebView, then the second WebView needs to scroll upto the section 1.1 which he reads in first WebView and viceversa. Also there are n number of sections.
I used following javacript but it needs the parameter of current div id. But on scroll, how can I get the current visible div id. I had given the id for each div.
function pointInView(id)
{
var divid = document.getElementById(id);
divid.scrollIntoView(true);
return false;
}
Anyone please help me.
I think jquery might be able to come to your rescue.
Could you use jQuery, since it's cross-browser compatible?
http://stackoverflow.com/questions/5353934/check-if-element-is-visible-on-screen
Check out answer form BenM
You don't really need a db entry for that. Just catch the click event via something like
$('.action').click(function(){
document.location = yourSecondFIleLocation+'?offset = ' + $('selectorDiv').detOffsetFromParentDiv(); //or get the scroll offset from the page.
});
and catch it on the second page either with php or jQuery to scroll to it.
Heck that is even achievable if you put in your code the paragraph marks and link correctly to them.
I searched a lot to get the div id from current scroll offsetbut didn't get the solution for it. So I go with the other option that, stored the start & end offsets of each section in both files. So I had created one look-up table in database & stored the start & end offsets of each section in both files.
ex. When user scrolls the first webview to section 1.1 & clicks the switch to open the second webview, then I scrolled the second webview to the section 1.1 in the second file.
Please try below,
To scroll any scroll view at any position we set the content offset of the scroll view.
To solve your problem we have two solutions,
In your case when user is viewing the first Web view, save the content offset of the first web view in any variable like below
CGFloat offset = webView1.scrollView.contentOffset.y; Then when you
open the second web view then provide this offset value to second
web view scroll offset.
Set
webView1.scrollView.contentOffset=webView2.scrollView.contentOffset
or vice versa according to your need
I hope this will help you.
Hello and thank you for reading.
I have an aspx form hosted in SharePoint 2010 that has some multiple select elements within a form. There are buttons to add and remove options from these select elements.
My problem is that I need to run a query based on the options within these multi select elements each time new options are added / removed from them. SharePoint is executing some server side code I don't have access to but here's my underlying problem.
If I hook into the buttons' onclick event, when my function is called the options have already been added to or removed from the select element. I need to capture the current option set of these elements, before the onclick function executes.
Is there another event I can tie into? Something like onbeforeclick on the buttons or optionsChanged on the multi select element? It doesn't look like any event will satisfy what I need to do here, but I'm hoping someone has faced a similar issue before.
Thanks,
Zachary Carter
The only solution I could come up with is to capture the present set of options each time an option is added or removed.
This solution is going to involve alot of array manipulation however, and if I can avoid that and simply tie into an event, before the onclick event of the button is called, that would be my ideal solution.
This might not be a great answer to your question, and if not, I apologize. However, I just ran into a very similar problem, albeit using Visual Basic. The solution wasn't elegant in my eyes, but I used VB's MouseUp event, which fires when the mouse button is released. On release (i.e., at the end of the previous action), I save all the information in the elements into an array, and then on the next click, before anything else happens, I can check against that array.
Edit: Gah, looks like you posted essentially that solution while I was typing. Sorry I didn't notice.