'Listview Y scroll position
Is there a way to get listview Y scroll position? My goal is to change TranslationY property of an image while the user scrolls the listview. I have achieved this before using a scrollview:
outerScrollView.Scrolled += (sender, e) => {
var imageHeight = 800;
var scrollRegion = layeringGrid.Height - outerScrollView.Height;
var parallexRegion = imageHeight - outerScrollView.Height;
var factor = outerScrollView.ScrollY - parallexRegion * (outerScrollView.ScrollY / scrollRegion);
imagesCarousel.TranslationY = factor;
};
However, listview does not contains the Scrolled event.
Thanks in advance.
Solution 1:[1]
ListViews by default have a scroll, don't know why your ListView doesn't contain the Scrolled event.
However once your ListView doesn't have a scroll by default you must create a scrollview covering you ListView in the xml like this:
<ScrollView x:Name="outerScrollView">
<ListView
x:Name="ItemsListView"
ItemsSource="{Binding Messages}"
HasUnevenRows="True"
/>
</ScrollView>
Then once you are in a event e, instead of outerScrollView.ScrollY you should use e.ScrollY
Implementing it in your code above should be something like this:
outerScrollView.Scrolled += (sender, e) => {
var imageHeight = 800;
var scrollRegion = layeringGrid.Height - e.Height;
var parallexRegion = imageHeight - e.Height;
var factor = e.ScrollY - parallexRegion * (e.ScrollY / scrollRegion);
imagesCarousel.TranslationY = factor;
};
That is it you have your scroll vertical position!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tghw |
