Get the Maximum and current value of Scrollbar in Listview - xamarin

As the title say:
I want to know values of a scrollbar in the ListView such as:
Minimum value I know = 0 :)
Maximum value of a scrollbar
Current value (position of a bar inside of a scrollbar)
Is this possible?
How to make it work for both iOS and Android?
I have tried with ItemAppear to get the position in the ListView but all I can get is the position of an item not the actual scrollbar position and with ItemAppear the problem is if I have big images in the list then I scroll 1 mile but nothing happens until the other item appears.

ListView doesn't fire Scrolled events like ScrollView does.
If you still want to get current value or maximum value of scrollbar, I suggest you can render new Listview, that contains scrolled event. or you can search some third party control, may be have this event.

Related

Detect the scrolling position of list view when little bit position changing(Without changing appearing item) also in xamarin forms

I want to find out the scroll view position of a list view, if we change the scrolling position little bit also. I have browse the net many solutions suggested that using 'ItemAppearing' event in list view but that event is not satisfying my requirement because that event fire only when item will be changed at the time of scrolling but In my list each item height is nearly equal to the my screen height that's for changing the item it takes large position of scrolling. Because of that after scrolling large position only that event will fired but what my requirement is just changing the little position of scrolling also need to detect that one. Please suggest any idea. Thanks in advance.

Appcelerator Titanium - Setting a View or Label max height

I have a list with titles coming from data source. The length of the title is unknown and could be one line, two lines and even more... under the title I want to place the name of the author of the post.
I placed the two labels (the title label and the author label inside a View with layout: 'vertical' which places the author label under the title label. But still had to somehow limit the number of rows displayed by the title - I want to have maximum 2 rows. So I've set the height of the subject label.
While setting the height of the label does limit the number of rows displayed, it causes another problem - on rows where the title is 2 lines or more everything looks great. but on rows where the title is only one row, there's now space between that row and the author name - and I want to have the author name right under the label (important thing to notice - the author label has a different font size and color than the title).
If it was just plain old html I would just set max-height css property - but Titanium doesn't have that kind of property on Views/Labels. Is there a way to have maximum height on a View?
There is no such property max-height being supported by Appcelerator for views. But what you can do is, you can listen for the postlayout event for the view and once triggered you can get the rect, to get the height of the view. Now in here you can do your magic. If the height of the view is greater than some value you want, then you can fix it, else let is remain as is.
Do let us know if it works for you. If not, we can try to come up with some other solution.
On Android you can use maxLines on a Label.
For Views and iOS you could do the following. Set the view's height:Ti.UI.SIZE and use bottom to set the minimum space between the views bottom and that of its parent. This only works if the parent has a fixed size.
Listening to post layout on a ListView won't work since you would have to set this on the ListView but don't have a way to access the rect or size property of the ListItem views.
I've just added the numberOfLines in the iOS SDK: https://jira.appcelerator.org/browse/TIMOB-24071
It's called maxLines for Android parity. It really works for Labels inside ListView templates.

trouble in scrolling in uitableview

I've created a Tableview populated with cells with a fixed tableView.rowHeight = 95.0
The problem is that when I add more cells and I try to scroll to the bottom, I can see only half cell at the bottom. I mean, when I try to scroll I can't scroll down so that to see the entire last cell added.
Seems the scrolling bar doesn't work well. Is this a bug of Xcode or did I make something wrong?
I don't want a resizable height cell but I want my cell fixed with with 95.0 but at the same time I want my scrollbar to work better.
The problem is if the table height exceeds the your mainview. At that time srollview of tableview also goes down.solution is keep the tableview height within the bounds of mainview(i.e your viewcontroller's view)

How to center selectedItem in listbox in wp7?

I use listbox.ScrollIntoView(item), but as long as this item is in listbox view, it won't scroll.
Actually I want the item to be centered in the listbox's view. Is there anyway to do this?
Unfortunately this is not all that easy, it depends on whether your listbox is virtualized or not, which depends on the panel that it uses to render its contents. For a non-virtualizing listbox, you can set the vertical scroll position by invoking the following method on the ScrollViewer which is part of the listbox template, where offset is in pixels.
ScrollViewer.ScrollToVerticalOffset(offset);
For virtualizing, you can invoke the following method on the VirtualizingStackPanel, where offset is the list location (you can use a double value, i.e. scrolling to 3.5 will scroll to half way between index 3 and 4):
ItemsHostStackPanel.SetVerticalOffset(offset);
For how to use this code in context, look at the jump list control I implemented here:
http://wp7contrib.codeplex.com/SourceControl/changeset/view/72741#1502048

WP7 listbox scroll by item

I have listbox in WP7 where i need to scroll to certain items according to user choice and i use scrolltoview for that. Problem is that i need listbox to scroll listbox enough so that selected item appears aligned to top edge. Right now scrolled item is positioned at bottom.
Assuming that you have fixed (and known) size items and a fixed (and known) size of listbox, can't you just account for the number of items between the top and bottom of the visible space and adjust your offset accordingly?
Unfortunately Matt solution was unusable in this case because listbox items were too big taking almost whole screen per item. But i was able to solve this problem by getting scrollviewer of listbox and use its scroll method to scroll into listbox SelectedIndex. Item is still not positioned perfectly after scrolling but height difference is minimal and acceptable for me.

Resources